Skip to content

Instantly share code, notes, and snippets.

View rande's full-sized avatar
🖖
hello!

Thomas rande

🖖
hello!
View GitHub Profile
<?php
/*
* This file is part of the Sonata package.
*
* (c) Thomas Rabaix <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
<?php
/*
* This file is part of the Sonata package.
*
* (c) Thomas Rabaix <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
{% set form %}
{% block form %}{% endblock %}
{% endset %}
{% if form|length > 0 %}
<div class="sonata-ba-form">
{{ form|raw }}
</div>
{% endif %}
sonata_media:
contexts:
defaults:
providers:
- sonata.media.provider.dailymotion
- sonata.media.provider.youtube
- sonata.media.provider.image
- sonata.media.provider.file
formats:
small: { width: 100 , quality: 70}
sonata_media:
contexts:
defaults:
providers:
- sonata.media.provider.dailymotion
- sonata.media.provider.youtube
- sonata.media.provider.image
- sonata.media.provider.file
news:
@rande
rande / gist:915243
Created April 12, 2011 09:30
sonata:admin:explain sonata.news.admin.post
id : sonata.news.admin.post
Model : Application\Sonata\NewsBundle\Entity\Post
Controller : SonataNewsBundle:PostAdmin
Routes
- admin_sonata_news_post_list
- admin_sonata_news_post_create
- admin_sonata_news_post_update
- admin_sonata_news_post_batch
- admin_sonata_news_post_edit
@rande
rande / gist:977427
Created May 17, 2011 21:19
Behat steps
<?php
$steps->And('/^I press item "([^"]*)"$/', function($world, $xpath) {
$button = $world->getSession()->getDriver()->find($xpath);
$button = count($button) > 0 ? current($button) : null;
if (null === $button) {
throw new ElementNotFoundException('button', $xpath);
}
@rande
rande / gist:985705
Created May 22, 2011 17:48
Sonata Security - Roles definitions
sonata_admin:
access_control:
- { path: ^/admin/sonata/media/media/list$, roles: [ROLE_SONATA_MEDIA_ADMIN_MEDIA_LIST], methods: null }
- { path: ^/admin/sonata/media/media/create$, roles: [ROLE_SONATA_MEDIA_ADMIN_MEDIA_CREATE], methods: null }
- { path: ^/admin/sonata/media/media/update$, roles: [ROLE_SONATA_MEDIA_ADMIN_MEDIA_UPDATE], methods: null }
- { path: ^/admin/sonata/media/media/batch$, roles: [ROLE_SONATA_MEDIA_ADMIN_MEDIA_BATCH], methods: null }
- { path: ^/admin/sonata/media/media/(?P[^/]+?)/edit$, roles: [ROLE_SONATA_MEDIA_ADMIN_MEDIA_EDIT], methods: null }
- { path: ^/admin/sonata/media/media/(?P[^/]+?)/delete$, roles: [ROLE_SONATA_MEDIA_ADMIN_MEDIA_DELETE], methods: null }
- { path: ^/admin/sonata/media/media/(?P[^/]+?)/view$, roles: [ROLE_SONATA_MEDIA_ADMIN_MEDIA_VIEW], methods: null }
- { path: ^/admin/sonata/media/gallery/list$, roles: [ROLE_SONATA_MEDIA_ADMIN_GALLERY_LIST], methods: null }
With :
$this->get('doctrine.orm.default_entity_manager')->find('Application\Sonata\NewsBundle\Entity\Comment', 1);
$this->get('doctrine.orm.default_entity_manager')->find('Application\Sonata\NewsBundle\Entity\Post', 5);
Then only 1 query :
63 Query SELECT t0.name AS name1, t0.url AS url2, t0.email AS email3, t0.message AS message4, t0.status AS status5, t0.created_at AS created_at6, t0.updated_at AS updated_at7, t0.id AS id8, t0.post_id AS post_id9 FROM news__comment t0 WHERE t0.id = 1
With :
$this->get('doctrine.orm.default_entity_manager')->find('Application\Sonata\NewsBundle\Entity\Post', 5);
<?xml version="1.0" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping
http://symfony.com/schema/dic/services/constraint-mapping-1.0.xsd">
<class name="Application\Sonata\NewsBundle\Entity\Post">
<getter property="title">
<constraint name="NotBlank" />