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:4981650
Last active December 13, 2015 21:59
Sonata Media Bundle
===================
Media path generation: http://mycdn.com/context/01223/023/thumb_1232_small.jpg
1. CDN http://mycdn.com
2. Path Generator : context/01223/023
3. Thumbnail - internal generation: thumb_1232_small.jpg
4. Thumbnail - return the relative path: context/01223/023/thumb_1232_small.jpg
<?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\Bundle\ScreenyBundle\Consumer;
use Sonata\Bundle\ScreenyBundle\Screeny\UrlShotManager;
use PhpAmqpLib\Message\AMQPMessage;
use OldSound\RabbitMqBundle\RabbitMq\Producer;
class UrlShotConsumer
{
<?php
// this check prevents access to debug front controllers that are deployed by accident to production servers.
// feel free to remove this, extend it, or make something more sophisticated.
if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1',
'::1',
'84.14.82.2',
'88.175.92.100',
))) {
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']) {
@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:
<?php
// service
interface BlockExecuteFactoryInterface
{
function getExecutionContext(BlockInterface $block);
}
// object, one per block
interface BlockExecutionContextInterface
/**
* {@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');
}
@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);
@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')
;