Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow DIC direct access to doctrine.oxm.xml_marshaller and set up def…

…ault marshallers.

This was the only thing worth porting from OpensoftDoctrineOXMBundle you hadn't already
addressed.
  • Loading branch information...
commit 713af636b0dd17dad8384cbd2df74bc8ca42ef0a 1 parent b0ef44f
@richardfullmer richardfullmer authored
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']))
);
Please sign in to comment.
Something went wrong with that request. Please try again.