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:1896431
Created February 24, 2012 01:10
SonataMediaBundle : sonata_media_type template preview
<div>
<form method="POST">
{{ form_widget(form.media.binaryContent, {'attr': {'class': 'span8'}}) }}
{{ form_rest(form) }}
<input type="submit" class="btn" value="Preview Video"/>
</form>
</div>
@rande
rande / gist:1896425
Created February 24, 2012 01:08
SonataMediaBundle : sonata_media_type Form Type
<?php
namespace Sonata\Bundle\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sonata\Bundle\DemoBundle\Model\MediaPreview;
use Symfony\Component\HttpFoundation\Request;
class DemoController extends Controller
{
@rande
rande / gist:1865893
Created February 19, 2012 21:29
SEO Bundle's twig helpers
<html>
<head {{ sonata_seo_head_attributes() }}>
{{ sonata_seo_title() }}
{{ sonata_seo_metadatas() }}
</head>
<body class="sonata-bc">
<!-- page -->
@rande
rande / gist:1865874
Created February 19, 2012 21:25
PostController with SEO Information
<?php
class PostController extends Controller
{
/**
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @param $permalink
* @return \Symfony\Bundle\FrameworkBundle\Controller\Response
*/
public function viewAction($permalink)
@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
@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: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: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: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
<?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;