Skip to content

Instantly share code, notes, and snippets.

@Ph3nol
Created August 25, 2012 20:53
Show Gist options
  • Save Ph3nol/3470847 to your computer and use it in GitHub Desktop.
Save Ph3nol/3470847 to your computer and use it in GitHub Desktop.
Symfony DiC: register new Definition
<?php
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
// ...
$exampleDef = new DefinitionDecorator('coo_example.service_name');
$exampleDef
->addArgument(new Reference('doctrine', ContainerInterface::NULL_ON_INVALID_REFERENCE))
->addTag('doctrine.event_subscriber')
;
$container->setDefinition('coo_example.service_name.test', $exampleDef);
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment