/** * Load additional definitions, like naming of parent data provider. * * This method will register an event to the populate environment event in which the parent data provider container * will get loaded. * * @param ContainerInterface $container The container where the data shall be stored. * * @return void */ protected function loadAdditionalDefinitions(ContainerInterface $container) { if ($this->getFromDca('config/ptable')) { $containerName = $container->getName(); $this->getDispatcher()->addListener(PopulateEnvironmentEvent::NAME, function (PopulateEnvironmentEvent $event) use($containerName) { $environment = $event->getEnvironment(); $definition = $environment->getDataDefinition(); if ($definition->getName() !== $containerName) { return; } $parentName = $definition->getBasicDefinition()->getParentDataProvider(); $factory = DcGeneralFactory::deriveEmptyFromEnvironment($environment)->setContainerName($parentName); $parentDefinition = $factory->createContainer(); $environment->setParentDataDefinition($parentDefinition); }); } }
/** * Load all additional definitions, like naming of parent data provider etc. * * @param ContainerInterface $container The container where the data shall be stored. * * @param BuildDataDefinitionEvent $event The event being emitted. * * @return void */ protected function loadAdditionalDefinitions(ContainerInterface $container, BuildDataDefinitionEvent $event) { if (($providers = $this->getFromDca('dca_config/data_provider')) !== null) { $event->getDispatcher()->addListener(sprintf('%s[%s]', PopulateEnvironmentEvent::NAME, $container->getName()), function (PopulateEnvironmentEvent $event) { $environment = $event->getEnvironment(); $definition = $environment->getDataDefinition(); $parentName = $definition->getBasicDefinition()->getParentDataProvider(); if ($parentName) { $factory = DcGeneralFactory::deriveEmptyFromEnvironment($environment)->setContainerName($parentName); $parentDefinition = $factory->createContainer(); $environment->setParentDataDefinition($parentDefinition); } $rootName = $definition->getBasicDefinition()->getRootDataProvider(); if ($rootName) { $factory = DcGeneralFactory::deriveEmptyFromEnvironment($environment)->setContainerName($rootName); $rootDefinition = $factory->createContainer(); $environment->setRootDataDefinition($rootDefinition); } }); } }