Permalink
Browse files

Merge pull request #1 from richardfullmer/default-xml-marshaller

Allow DIC direct access to doctrine.oxm.xml_marshaller
  • Loading branch information...
2 parents b0ef44f + 713af63 commit 1f6d116d1db7f1ef6fd3ae47dfd78b6e12659756 @golovanov committed Jul 31, 2011
Showing with 17 additions and 0 deletions.
  1. +1 −0 DependencyInjection/Configuration.php
  2. +16 −0 DependencyInjection/DoctrineOXMExtension.php
View
1 DependencyInjection/Configuration.php
@@ -42,6 +42,7 @@ public function getConfigTreeBuilder()
->scalarNode('proxy_dir')->defaultValue('%kernel.cache_dir%/doctrine/oxm/Proxies')->end()
->scalarNode('auto_generate_proxy_classes')->defaultFalse()->end()
->scalarNode('default_xml_entity_manager')->end()
+ ->scalarNode('default_xml_marshaller')->end()
->scalarNode('default_storage')->defaultValue('default')->end()
->end()
;
View
16 DependencyInjection/DoctrineOXMExtension.php
@@ -41,6 +41,11 @@ public function load(array $configs, ContainerBuilder $container)
$config['default_storage'] = reset($keys);
}
+ if (empty ($config['default_xml_marshaller'])) {
+ $keys = array_keys($config['xml_entity_managers']);
+ $config['default_xml_marshaller'] = reset($keys);
+ }
+
if (empty ($config['default_xml_entity_manager'])) {
$keys = array_keys($config['xml_entity_managers']);
$config['default_xml_entity_manager'] = reset($keys);
@@ -84,6 +89,7 @@ protected function loadXmlEntityManagers(array $xemConfigs, $defaultXEM, $defaul
);
}
$container->setParameter('doctrine.oxm.xml_entity_managers', array_keys($xemConfigs));
+ $container->setParameter('doctrine.oxm.xml_marshallers', array_keys($xemConfigs));
}
/**
@@ -151,12 +157,22 @@ protected function loadXmlEntityManager(array $xmlEntityManager, $defaultXEM, $d
$oxmXemDef->addTag('doctrine.oxm.xml_entity_manager');
$container->setDefinition(sprintf('doctrine.oxm.%s_xml_entity_manager', $xmlEntityManager['name']), $oxmXemDef);
+ // oxm marshaller
+ $oxmMarshallerDef = new Definition('%doctrine.oxm.xml_marshaller.class%');
+ $oxmMarshallerDef->setFactoryService(sprintf('doctrine.oxm.%s_xml_entity_manager', $xmlEntityManager['name']));
+ $oxmMarshallerDef->setFactoryMethod('getMarshaller');
+ $container->setDefinition(sprintf('doctrine.oxm.%s_xml_marshaller', $xmlEntityManager['name']), $oxmMarshallerDef);
+
if ($xmlEntityManager['name'] == $defaultXEM) {
$container->setAlias(
'doctrine.oxm.xml_entity_manager',
new Alias(sprintf('doctrine.oxm.%s_xml_entity_manager', $xmlEntityManager['name']))
);
$container->setAlias(
+ 'doctrine.oxm.xml_marshaller',
+ new Alias(sprintf('doctrine.oxm.%s_xml_marshaller', $xmlEntityManager['name']))
+ );
+ $container->setAlias(
'doctrine.oxm.event_manager',
new Alias(sprintf('doctrine.oxm.%s_event_manager', $xmlEntityManager['name']))
);

0 comments on commit 1f6d116

Please sign in to comment.