public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     $reflectionReader = $builder->addDefinition($this->prefix('reflectionReader'))->setClass('Doctrine\\Common\\Annotations\\AnnotationReader')->setAutowired(FALSE);
     Validators::assertField($config, 'ignore', 'array');
     foreach ($config['ignore'] as $annotationName) {
         $reflectionReader->addSetup('addGlobalIgnoredName', array($annotationName));
     }
     $builder->addDefinition($this->prefix('reader'))->setClass('Doctrine\\Common\\Annotations\\Reader')->setFactory('Doctrine\\Common\\Annotations\\CachedReader', array($this->prefix('@reflectionReader'), Helpers::processCache($this, $config['cache'], 'annotations'), $config['debug']))->setInject(FALSE);
     // for runtime
     AnnotationRegistry::registerLoader("class_exists");
 }
 public function loadConfiguration()
 {
     $this->validateConfig($this->defaults);
     Validators::assertField($this->config, 'validateOnFlush', 'bool|list');
     $builder = $this->getContainerBuilder();
     if ($this->getExtension('Arachne\\EntityLoader\\DI\\EntityLoaderExtension', false)) {
         /* @var $serviceCollectionsExtension ServiceCollectionsExtension */
         $serviceCollectionsExtension = $this->getExtension('Arachne\\ServiceCollections\\DI\\ServiceCollectionsExtension');
         $serviceCollectionsExtension->overrideCollection(ServiceCollectionsExtension::TYPE_RESOLVER, EntityLoaderExtension::TAG_FILTER_IN, function ($originalService) use($builder) {
             $service = $this->prefix('entityLoader.filterInResolver');
             $builder->addDefinition($service)->setClass('Arachne\\Doctrine\\EntityLoader\\FilterInResolver')->setArguments(['resolver' => '@' . $originalService])->setAutowired(false);
             return $service;
         });
         $serviceCollectionsExtension->overrideCollection(ServiceCollectionsExtension::TYPE_RESOLVER, EntityLoaderExtension::TAG_FILTER_OUT, function ($originalService) use($builder) {
             $service = $this->prefix('entityLoader.filterOutResolver');
             $builder->addDefinition($service)->setClass('Arachne\\Doctrine\\EntityLoader\\FilterOutResolver')->setArguments(['resolver' => '@' . $originalService])->setAutowired(false);
             return $service;
         });
     }
     if ($this->getExtension('Kdyby\\Validator\\DI\\ValidatorExtension', false)) {
         $builder->addDefinition($this->prefix('validator.constraint.uniqueEntity'))->setClass('Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\UniqueEntityValidator')->addTag(ValidatorExtension::TAG_CONSTRAINT_VALIDATOR, ['Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\UniqueEntityValidator', 'doctrine.orm.validator.unique']);
         $builder->addDefinition($this->prefix('validator.initializer'))->setClass('Symfony\\Bridge\\Doctrine\\Validator\\DoctrineInitializer')->addTag(ValidatorExtension::TAG_INITIALIZER);
         if ($this->config['validateOnFlush']) {
             $listener = $builder->addDefinition($this->prefix('validator.validatorListener'))->setClass('Arachne\\Doctrine\\Validator\\ValidatorListener')->setArguments(['groups' => is_array($this->config['validateOnFlush']) ? $this->config['validateOnFlush'] : null]);
             if ($this->getExtension('Arachne\\EventManager\\DI\\EventManagerExtension', false)) {
                 $listener->addTag(EventManagerExtension::TAG_SUBSCRIBER);
             } elseif ($this->getExtension('Kdyby\\Events\\DI\\EventsExtension', false)) {
                 $listener->addTag(EventsExtension::TAG_SUBSCRIBER);
             } else {
                 throw new AssertionException("The 'validateOnFlush' option requires either Arachne/EventManager or Kdyby/Events to be installed.");
             }
         }
     } elseif ($this->config['validateOnFlush']) {
         throw new AssertionException("The 'validateOnFlush' option requires Kdyby/Validator to be installed.");
     }
     if ($this->getExtension('Arachne\\Forms\\DI\\FormsExtension', false)) {
         $builder->addDefinition($this->prefix('forms.typeGuesser'))->setClass('Symfony\\Bridge\\Doctrine\\Form\\DoctrineOrmTypeGuesser')->addTag(FormsExtension::TAG_TYPE_GUESSER)->setAutowired(false);
         $builder->addDefinition($this->prefix('forms.type.entity'))->setClass('Symfony\\Bridge\\Doctrine\\Form\\Type\\EntityType')->addTag(FormsExtension::TAG_TYPE, ['Symfony\\Bridge\\Doctrine\\Form\\Type\\EntityType'])->setAutowired(false);
     }
     if ($this->getExtension('Arachne\\ExpressionLanguage\\DI\\ExpressionLanguageExtension', false)) {
         $builder->addDefinition($this->prefix('expressionLanguage.parserCache'))->setClass('Symfony\\Component\\ExpressionLanguage\\ParserCache\\ParserCacheInterface')->setFactory('Symfony\\Bridge\\Doctrine\\ExpressionLanguage\\DoctrineParserCache', ['cache' => Helpers::processCache($this, $this->config['expressionLanguageCache'], 'expressionLanguage', $this->config['debug'])]);
     }
 }
 public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     $configuration = $builder->addDefinition($this->prefix('config'))->setClass('Doctrine\\Search\\Configuration')->addSetup('setMetadataCacheImpl', array(CacheHelpers::processCache($this, $config['metadataCache'], 'metadata', $config['debugger'])))->addSetup('setObjectManager', array('@Doctrine\\ORM\\EntityManager'))->addSetup('setIndexPrefix', array($config['indexPrefix']));
     $this->loadSerializer($config);
     $configuration->addSetup('setEntitySerializer', array($this->prefix('@serializer')));
     $builder->addDefinition($this->prefix('driver'))->setClass('Doctrine\\Search\\Mapping\\Driver\\DependentMappingDriver', array($this->prefix('@driverChain')))->setAutowired(FALSE);
     $configuration->addSetup('setMetadataDriverImpl', array($this->prefix('@driver')));
     $metadataDriverChain = $builder->addDefinition($this->prefix('driverChain'))->setClass('Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriverChain')->setAutowired(FALSE);
     foreach ($config['metadata'] as $namespace => $directory) {
         $metadataDriverChain->addSetup('addDriver', array(new Nette\DI\Statement('Doctrine\\Search\\Mapping\\Driver\\NeonDriver', array($directory)), $namespace));
     }
     $builder->addDefinition($this->prefix('client'))->setClass('Doctrine\\Search\\ElasticSearch\\Client', array('@Elastica\\Client'));
     $builder->addDefinition($this->prefix('evm'))->setClass('Kdyby\\Events\\NamespacedEventManager', array(Kdyby\DoctrineSearch\Events::NS . '::'))->setAutowired(FALSE);
     $builder->addDefinition($this->prefix('manager'))->setClass('Doctrine\\Search\\SearchManager', array($this->prefix('@config'), $this->prefix('@client'), $this->prefix('@evm')));
     $builder->addDefinition($this->prefix('searchableListener'))->setClass('Kdyby\\DoctrineSearch\\SearchableListener')->addTag('kdyby.subscriber');
     $builder->addDefinition($this->prefix('schema'))->setClass('Kdyby\\DoctrineSearch\\SchemaManager', array($this->prefix('@client')));
     $builder->addDefinition($this->prefix('entityPiper'))->setClass('Kdyby\\DoctrineSearch\\EntityPiper');
     $this->loadConsole();
 }
 public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     $builder->addDefinition($this->prefix('loader'))->setClass('Symfony\\Component\\Validator\\Mapping\\Loader\\LoaderInterface')->setFactory('Symfony\\Component\\Validator\\Mapping\\Loader\\LoaderChain');
     $cacheService = $builder->addDefinition($this->prefix('cache'))->setClass('Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface');
     $cacheFactory = self::filterArgs($config['cache']);
     if (class_exists($cacheFactory[0]->getEntity()) && in_array('Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface', class_implements($cacheFactory[0]->getEntity()), TRUE)) {
         $cacheService->setFactory($cacheFactory[0]->getEntity(), $cacheFactory[0]->arguments);
     } else {
         $cacheService->setFactory('Symfony\\Component\\Validator\\Mapping\\Cache\\DoctrineCache', [Helpers::processCache($this, $config['cache'], 'validator', $config['debug'])]);
     }
     $builder->addDefinition($this->prefix('metadataFactory'))->setClass('Symfony\\Component\\Validator\\Mapping\\Factory\\MetadataFactoryInterface')->setFactory('Symfony\\Component\\Validator\\Mapping\\Factory\\LazyLoadingMetadataFactory')->setAutowired(FALSE);
     $builder->addDefinition($this->prefix('constraintValidatorFactory'))->setClass('Symfony\\Component\\Validator\\ConstraintValidatorFactoryInterface')->setFactory('Kdyby\\Validator\\ConstraintValidatorFactory');
     $builder->addDefinition($this->prefix('contextFactory'))->setClass('Symfony\\Component\\Validator\\Context\\ExecutionContextFactoryInterface')->setFactory('Symfony\\Component\\Validator\\Context\\ExecutionContextFactory', ['translationDomain' => $config['translationDomain']]);
     $builder->addDefinition($this->prefix('validator'))->setClass('Symfony\\Component\\Validator\\Validator\\ValidatorInterface')->setFactory('Symfony\\Component\\Validator\\Validator\\RecursiveValidator');
     Validators::assertField($config, 'strictEmail', 'boolean');
     $builder->addDefinition($this->prefix('constraint.email'))->setClass('Symfony\\Component\\Validator\\Constraints\\EmailValidator')->setArguments(['strict' => $config['strictEmail']])->addTag(self::TAG_CONSTRAINT_VALIDATOR);
     $builder->addDefinition($this->prefix('constraint.expression'))->setClass('Symfony\\Component\\Validator\\Constraints\\ExpressionValidator')->addTag(self::TAG_CONSTRAINT_VALIDATOR, ['validator.expression']);
     if ($this->compiler->getExtensions('Kdyby\\Annotations\\DI\\AnnotationsExtension')) {
         $builder->addDefinition($this->prefix('annotationsLoader'))->setFactory('Symfony\\Component\\Validator\\Mapping\\Loader\\AnnotationLoader')->addTag(self::TAG_LOADER);
     }
 }
Exemple #5
0
 /**
  * @param string|\stdClass $cache
  * @param string $suffix
  * @return string
  */
 protected function processCache($cache, $suffix)
 {
     return CacheHelpers::processCache($this, $cache, $suffix, $this->getContainerBuilder()->parameters[$this->prefix('debug')]);
 }