Skip to content

Instantly share code, notes, and snippets.

View rande's full-sized avatar
🖖
hello!

Thomas rande

🖖
hello!
View GitHub Profile
@rande
rande / gist:987737
Created May 23, 2011 22:13
Validation issue
<?php
class Model
{
protected $name = 'toto';
public function getName()
{
return $this->name;
}
@rande
rande / gist:1016464
Created June 9, 2011 10:10
PageBundle with Page's Snapshot
<?php
class PageController extends Controller
{
public function catchAllAction()
{
$pathInfo = $this->get('request')->getPathInfo();
$snapshotManager = $this->get('sonata.page.manager.snapshot');
diff --git a/Form/ChoiceList/ModelChoiceList.php b/Form/ChoiceList/ModelChoiceList.php
index e67befd..f95ca6d 100644
--- a/Form/ChoiceList/ModelChoiceList.php
+++ b/Form/ChoiceList/ModelChoiceList.php
@@ -111,7 +111,7 @@ class ModelChoiceList extends ArrayChoiceList
{
parent::load();
- if ($this->choices) {
+ if (is_array($this->choices)) {
@rande
rande / gist:1042156
Created June 23, 2011 08:31
Rss Block Service
<?php
/*
* This file is part of the Sonata project.
*
* (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
namespace Sonata\PageBundle\Block;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Form\Form;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\PageBundle\Model\BlockInterface;
use Sonata\PageBundle\Model\PageInterface;
use Sonata\AdminBundle\Validator\ErrorElement;
@rande
rande / gist:1119984
Created August 2, 2011 10:31
Simulate Association and Reuse Admin code
<?php
// simulate an association ...
$fieldDescription = $formMapper->getAdmin()->getModelManager()->getNewFieldDescriptionInstance($this->mediaAdmin->getClass(), 'media' );
$fieldDescription->setAssociationAdmin($this->getMediaAdmin());
$fieldDescription->setAdmin($formMapper->getAdmin());
$fieldDescription->setOption('edit', 'list');
$fieldDescription->setAssociationMapping(array('fieldName' => 'media', 'type' => \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_ONE));
// create the builder
@rande
rande / gist:1231519
Created September 21, 2011 08:02
SonataFormatterBundle : Mixin Markdown syntax and Twig extension
# This is a heading 1
## This is a heading 2
Let's include a media from the SonataMediaBundle :
<center>
<% media 3, 'small' %>
</center>
@rande
rande / gist:1528471
Created December 28, 2011 16:02
Symfony2 & Drush
bash-3.2$ ./drush default cc
[Symfony2] Booting Kernel ... ok!
[Symfony2] Loading container ... ok!
Enter a number to choose which cache to clear.
[0] : Cancel
[1] : all
[2] : theme registry
[3] : menu
[4] : css+js
@rande
rande / gist:1552362
Created January 2, 2012 22:19
Sonata Formatter Bundle
## The Sonata Formatter Bundle
The formatter bundle allows to format a text in different format :
* markdown
* nl2br
* raw html
More formatter can be added as long as the correct interface is respected.
@rande
rande / gist:1865854
Created February 19, 2012 21:19
Sonata SEO configuration
#
# more information can be found here http://sonata-project.org/bundles/page
#
sonata_seo:
default: sonata.seo.page.default
title: Sonata Project
metas:
name:
keywords: foo bar
description: The description