/** * @param ContainerBuilder $container * @throws \Exception */ protected function injectCommonServices(ContainerBuilder $container) { $config = $container->getParameter('knd_rad.auto_inject.common'); $types = null; $def = null; if ($container->hasDefinition('form.extension')) { $types = $container->getDefinition('form.extension')->getArgument(1); } foreach ($this->getClasses($config['dirs'], $config['classes'], $config['exclude_classes']) as $class) { $reflClass = $this->reflectionFactory->createReflectionClass($class); if ($reflClass->isAbstract()) { continue; } $classContainerParameter = $this->injectClassContainerParameter($container, $class); if ($reflClass->implementsInterface('Symfony\\Component\\Form\\FormTypeInterface')) { $id = $this->containerIdGenerator->getFormTypeServiceId($class); if ($container->hasDefinition($id)) { continue; } if (false === $container->hasDefinition('form.extension')) { continue; } $def = $this->definitionFactory->createFormTypeDefinition($class, $classContainerParameter); $alias = $this->containerIdGenerator->getFormTypeAlias($class); $types[$alias] = $id; } elseif ($reflClass->isSubclassOf('Doctrine\\ORM\\EntityRepository')) { continue; } elseif ($reflClass->isSubclassOf('Knd\\Bundle\\RadBundle\\Manager\\Manager')) { continue; } elseif ($reflClass->isSubclassOf('Knd\\Bundle\\RadBundle\\Security\\Voter\\AbstractVoter')) { $id = $this->containerIdGenerator->getModelVoterServiceId($class); $def = $this->definitionFactory->createModelVoterDefinition($class, $classContainerParameter); } else { $id = $this->containerIdGenerator->getServiceId($class); if ($container->hasDefinition($id)) { continue; } $def = $this->definitionFactory->createDefinition($class, $classContainerParameter); } if ($def) { $container->setDefinition($id, $def); } } if ($container->hasDefinition('form.extension')) { $container->getDefinition('form.extension')->replaceArgument(1, $types); } }
/** * @return EntityRepository */ public function getRepository() { return $this->get($this->containerIdGenerator->getEntityRepositoryServiceId($this->getClass())); }