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: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: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: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: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:1900366
Created February 24, 2012 11:39
SEO Bundle - Define Parameters
<?php
$this->getSeoPage()
->setTitle($media->getName())
->addMeta('property', 'og:description', $media->getDescription())
->addMeta('property', 'og:type', 'video')
;
@rande
rande / gist:1901137
Created February 24, 2012 14:08
SonataMediaBundle : persist media
<?php
$media = new Media;
$media->setProviderName('sonata.media.provider.image');
$media->setContext('default');
$media->setBinaryContent('/path/to/file');
$post = new Post;
$post->setMedia($media);
/**
* {@inheritdoc}
*/
public function getStatus()
{
$states = $this->messageManager->countStates();
if ($states[MessageInterface::STATE_OPEN] > $this->checkLevel[MessageInterface::STATE_OPEN]) {
return new BackendStatus(BackendStatus::CRITICAL, 'Too much messages waiting to be processed');
}
<?php
// service
interface BlockExecuteFactoryInterface
{
function getExecutionContext(BlockInterface $block);
}
// object, one per block
interface BlockExecutionContextInterface
@rande
rande / assetic.yml
Created May 14, 2012 22:16
assetic assets packages
assetic:
debug: false
use_controller: false
read_from: %kernel.root_dir%/../web
write_to: %kernel.root_dir%/../web
dump_on_warmup: false # do not compile on cache warmup
bundles: [] # disable bundles parsing
filters:
yui_js:
diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php
index 2cad8a4..51c4924 100644
--- a/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php
+++ b/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php
@@ -127,6 +127,16 @@ class XmlExporter extends AbstractExporter
}
}
+ foreach ($metadata->associationMappings as $name => $field) {
+ if (isset($field['id']) && $field['id']) {