当前位置: 首页>>代码示例>>PHP>>正文


PHP Definition::setFactoryService方法代码示例

本文整理汇总了PHP中Symfony\Component\DependencyInjection\Definition::setFactoryService方法的典型用法代码示例。如果您正苦于以下问题:PHP Definition::setFactoryService方法的具体用法?PHP Definition::setFactoryService怎么用?PHP Definition::setFactoryService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\DependencyInjection\Definition的用法示例。


在下文中一共展示了Definition::setFactoryService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: reflectDefinition

 protected function reflectDefinition($reflClass)
 {
     $definition = new Definition($reflClass->getName());
     if ($annot = $this->reader->getClassAnnotation($reflClass, 'LoSo\\Symfony\\Component\\DependencyInjection\\Loader\\Annotation\\Service')) {
         $id = $this->extractServiceName($reflClass, $annot);
         if (isset($annot->shared)) {
             $definition->setShared($annot->shared);
         }
         if (isset($annot->factoryMethod)) {
             $definition->setFactoryMethod($annot->factoryMethod);
         }
         if (isset($annot->factoryService)) {
             $definition->setFactoryService($annot->factoryService);
         }
         foreach ($annot->tags as $tag) {
             $name = $tag['name'];
             unset($tag['name']);
             $definition->addTag($name, $tag);
         }
         $this->reflectProperties($reflClass, $definition);
         $this->reflectMethods($reflClass, $definition);
         $this->reflectConstructor($reflClass, $definition);
         $this->container->setDefinition($id, $definition);
     }
 }
开发者ID:nuxwin,项目名称:losolib,代码行数:25,代码来源:AnnotationLoader.php

示例2: loadDbalConnection

 /**
  * Loads a configured DBAL connection.
  *
  * @param string $name The name of the connection
  * @param array $connection A dbal connection configuration.
  * @param ContainerBuilder $container A ContainerBuilder instance
  */
 protected function loadDbalConnection($name, array $connection, ContainerBuilder $container)
 {
     $containerDef = new Definition('%doctrine.dbal.configuration_class%');
     $containerDef->setPublic(false);
     if (isset($connection['logging']) && $connection['logging']) {
         $containerDef->addMethodCall('setSQLLogger', array(new Reference('doctrine.dbal.logger')));
         unset($connection['logging']);
     }
     $container->setDefinition(sprintf('doctrine.dbal.%s_connection.configuration', $name), $containerDef);
     $driverDef = new Definition('Doctrine\\DBAL\\Connection');
     $driverDef->setFactoryService('doctrine.dbal.connection_factory');
     $driverDef->setFactoryMethod('createConnection');
     $container->setDefinition(sprintf('doctrine.dbal.%s_connection', $name), $driverDef);
     // event manager
     $eventManagerId = sprintf('doctrine.dbal.%s_connection.event_manager', $name);
     $eventManagerDef = new Definition('%doctrine.dbal.event_manager_class%');
     $eventManagerDef->setPublic(false);
     $container->setDefinition($eventManagerId, $eventManagerDef);
     if (isset($connection['charset'])) {
         if (isset($connection['driver']) && stripos($connection['driver'], 'mysql') !== false || isset($connection['driverClass']) && stripos($connection['driverClass'], 'mysql') !== false) {
             $mysqlSessionInit = new Definition('%doctrine.dbal.events.mysql_session_init.class%');
             $mysqlSessionInit->setArguments(array($connection['charset']));
             $mysqlSessionInit->setPublic(false);
             $mysqlSessionInit->addTag(sprintf('doctrine.dbal.%s_event_subscriber', $name));
             $container->setDefinition(sprintf('doctrine.dbal.%s_connection.events.mysqlsessioninit', $name), $mysqlSessionInit);
             unset($connection['charset']);
         }
     }
     if (isset($connection['platform_service'])) {
         $connection['platform'] = new Reference($connection['platform_service']);
         unset($connection['platform_service']);
     }
     $driverDef->setArguments(array($connection, new Reference(sprintf('doctrine.dbal.%s_connection.configuration', $name)), new Reference(sprintf('doctrine.dbal.%s_connection.event_manager', $name))));
 }
开发者ID:naderman,项目名称:symfony,代码行数:41,代码来源:DoctrineExtension.php

示例3: load

 /**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.yml');
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     $def = $container->getDefinition('socloz.nsq');
     if ($config['lookupd_hosts']) {
         $container->setDefinition('socloz.nsq.lookup', new Definition('nsqphp\\Lookup\\Nsqlookupd', array($config['lookupd_hosts'])));
     }
     $def->addMethodCall('setDelayedMessagesTopic', array($config['delayed_messages_topic']));
     $def->addMethodCall('setStubMode', array($config['stub']));
     foreach ($config['topics'] as $name => $conf) {
         $def->addMethodCall('setTopic', array($name, $conf));
         if ($conf['consumers']) {
             foreach ($conf['consumers'] as $channel => $service) {
                 $def->addMethodCall('setTopicConsumer', array($name, $channel, new Reference($service)));
             }
         }
         $tsd = new Definition('Socloz\\NsqBundle\\Topic\\Topic', array($name));
         $tsd->setFactoryService('socloz.nsq');
         $tsd->setFactoryMethod('getTopic');
         $container->setDefinition('socloz.nsq.topic.' . $name, $tsd);
     }
 }
开发者ID:smilesrg,项目名称:NsqBundle,代码行数:28,代码来源:SoclozNsqExtension.php

示例4: getEntityMetadataDefinition

 public function getEntityMetadataDefinition($entity, $entityManager)
 {
     $definition = new Definition('Doctrine\\ORM\\Mapping\\ClassMetadata');
     $definition->setFactoryService($this->resolveEntityManagerId($entityManager));
     $definition->setFactoryMethod('getClassMetadata');
     $definition->setArguments(array($entity));
     return $definition;
 }
开发者ID:0mars,项目名称:losolib,代码行数:8,代码来源:DoctrineServicesUtils.php

示例5: buildUseCaseProxyFactoryDefinition

 private function buildUseCaseProxyFactoryDefinition($taggedServiceName, $tagParameters)
 {
     $definition = $this->container->findDefinition($taggedServiceName);
     $factoryDefinition = new Definition();
     $factoryDefinition->setFactoryService('openclassrooms.use_case.use_case_proxy_factory');
     $factoryDefinition->setFactoryMethod('create');
     $factoryDefinition->setArguments(array($definition, $tagParameters[0]));
     $this->container->setDefinition($taggedServiceName, $factoryDefinition);
 }
开发者ID:arnaud-23,项目名称:UseCaseBundle,代码行数:9,代码来源:UseCaseProxyPass.php

示例6: prepareRepositoriesServices

 protected function prepareRepositoriesServices($classes, ContainerBuilder $container, $appName)
 {
     foreach (array_keys($classes) as $model) {
         $repositoryClassKey = $this->getParameterName($appName, 'repository', $model);
         $repositoryClass = $container->getParameter($repositoryClassKey);
         $repositoryDefinition = new Definition($repositoryClass);
         $repositoryDefinition->setFactoryService('doctrine.orm.entity_manager')->setFactoryMethod('getRepository')->setArguments([$container->getParameter($this->getParameterName($appName, 'model', $model))]);
         $container->setDefinition($appName . '.repository.' . $model, $repositoryDefinition);
     }
 }
开发者ID:webility,项目名称:entity-resource-bundle,代码行数:10,代码来源:ResourceExtensionTrait.php

示例7: testProcessDetectsReferencesFromInlinedFactoryDefinitions

 public function testProcessDetectsReferencesFromInlinedFactoryDefinitions()
 {
     $container = new ContainerBuilder();
     $container->register('a');
     $factory = new Definition();
     $factory->setFactoryService('a');
     $container->register('b')->addArgument($factory);
     $graph = $this->process($container);
     $this->assertTrue($graph->hasNode('a'));
     $this->assertCount(1, $refs = $graph->getNode('a')->getInEdges());
 }
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:11,代码来源:AnalyzeServiceReferencesPassTest.php

示例8: resolveString

 public function resolveString($value, array $resolved = array())
 {
     if (preg_match('/\\&([^\\&\\s]+)\\&$/', $value, $match)) {
         $definition = new Definition();
         $definition->setFactoryService('service_container');
         $definition->setFactoryMethod('getVariable');
         $definition->setArguments(array($match[1]));
         return $definition;
     }
     return $value;
 }
开发者ID:frizinak,项目名称:drupony,代码行数:11,代码来源:DrupalVariableBag.php

示例9: testResolveFactoryService

 /**
  * @group legacy
  */
 public function testResolveFactoryService()
 {
     $container = new ContainerBuilder();
     $container->register('factory', 'Factory');
     $container->setAlias('factory_alias', new Alias('factory'));
     $foo = new Definition();
     $foo->setFactoryService('factory_alias');
     $foo->setFactoryMethod('createFoo');
     $container->setDefinition('foo', $foo);
     $this->process($container);
     $this->assertSame('factory', $foo->getFactoryService());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:ResolveReferencesToAliasesPassTest.php

示例10: createGateway

 /**
  * @param ContainerBuilder $container
  * @param $gatewayName
  * @param array $config
  *
  * @return Definition
  */
 protected function createGateway(ContainerBuilder $container, $gatewayName, array $config)
 {
     $gatewayFactoryClass = $this->getPayumGatewayFactoryClass();
     if (false == class_exists($gatewayFactoryClass)) {
         throw new RuntimeException(sprintf('Cannot find gateway factory class. Have you installed %s or payum/payum package?', $this->getComposerPackage()));
     }
     $config['payum.gateway_name'] = $gatewayName;
     $gateway = new Definition('Payum\\Core\\Gateway', array($config));
     $gateway->setFactoryService(sprintf('payum.%s.factory', $this->getName()));
     $gateway->setFactoryMethod('create');
     return $gateway;
 }
开发者ID:Raxer971,项目名称:challenge,代码行数:19,代码来源:AbstractGatewayFactory.php

示例11: getRepositoryDefinition

 /**
  * {@inheritdoc}
  */
 protected function getRepositoryDefinition(array $classes)
 {
     $repositoryClass = 'Sylius\\Bundle\\ResourceBundle\\Doctrine\\ODM\\MongoDB\\DocumentRepository';
     if (isset($classes['repository'])) {
         $repositoryClass = $classes['repository'];
     }
     $unitOfWorkDefinition = new Definition('Doctrine\\ODM\\MongoDB\\UnitOfWork');
     $unitOfWorkDefinition->setFactoryService($this->getManagerServiceKey())->setFactoryMethod('getUnitOfWork')->setPublic(false);
     $definition = new Definition($repositoryClass);
     $definition->setArguments(array(new Reference($this->getContainerKey('manager')), $unitOfWorkDefinition, $this->getClassMetadataDefinition($classes['model'])));
     return $definition;
 }
开发者ID:Avazanga1,项目名称:Sylius,代码行数:15,代码来源:DoctrineODMDriver.php

示例12: loadClientConnection

 protected function loadClientConnection($name, array $connection, ContainerBuilder $container)
 {
     $container->setDefinition(sprintf('doctrine_couchdb.client.%s_connection', $name), new DefinitionDecorator('doctrine_couchdb.client.connection'))->setArguments(array($connection));
     if (isset($connection['logging']) && $connection['logging'] === true) {
         $def = new Definition('Doctrine\\CouchDB\\HTTP\\Client');
         $def->setFactoryService(sprintf('doctrine_couchdb.client.%s_connection', $name));
         $def->setFactoryMethod('getHttpClient');
         $def->setPublic(false);
         $container->setDefinition(sprintf('doctrine_couchdb.httpclient.%s_client', $name), $def);
         $def = $container->getDefinition('doctrine_couchdb.datacollector');
         $def->addMethodCall('addLoggingClient', array(new Reference(sprintf('doctrine_couchdb.httpclient.%s_client', $name)), $name));
     }
 }
开发者ID:ruian,项目名称:DoctrineCouchDBBundle,代码行数:13,代码来源:DoctrineCouchDBExtension.php

示例13: load

 /**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     $container->setParameter('kalamu_menu_service.menus', $config);
     foreach ($config as $name => $infos) {
         $definition = new Definition('Knp\\Menu\\MenuItem', array($name));
         $definition->setFactoryService('kalamu_menu_service.menu_builder');
         $definition->setFactoryMethod('createMenu');
         $definition->addTag('knp_menu.menu', array('alias' => $name));
         $container->setDefinition('kalamu_menu_service.menu.' . $name, $definition);
     }
     $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.yml');
 }
开发者ID:kalamu,项目名称:menu-service-bundle,代码行数:18,代码来源:KalamuMenuServiceExtension.php

示例14: getServiceFactory

 /**
  * return from local cache or make a new one and put it in cache and then return it.
  * @param ContainerBuilder $container
  * @param string $contextName
  * @returns Reference The service definition reference
  */
 private function getServiceFactory(ContainerBuilder $container, $contextName)
 {
     if (!array_key_exists($contextName, $this->serviceDefinistions)) {
         $def = new Definition();
         $def->setClass('TechData\\ContextDiBundle\\Models\\Context');
         $def->setLazy(TRUE);
         $def->setFactoryService('tech_data_context_di.context_handler');
         $def->setFactoryMethod('getContext');
         $def->setArguments(array($contextName));
         $id = 'tech_data_context_di.contexts.' . $contextName;
         $container->setDefinition($id, $def);
         $this->serviceDefinistions[$contextName] = new Reference($id);
     }
     return $this->serviceDefinistions[$contextName];
 }
开发者ID:TechData,项目名称:ContextDI,代码行数:21,代码来源:ContextConsumerCompilerPass.php

示例15: getRepositoryDefinition

 /**
  * {@inheritdoc}
  */
 protected function getRepositoryDefinition(array $classes)
 {
     $reflection = new \ReflectionClass($classes['model']);
     $translatableInterface = 'Sylius\\Component\\Translation\\Model\\TranslatableInterface';
     $translatable = interface_exists($translatableInterface) && $reflection->implementsInterface($translatableInterface);
     $repositoryClass = $translatable ? 'Sylius\\Bundle\\TranslationBundle\\Doctrine\\ODM\\MongoDB\\TranslatableResourceRepository' : new Parameter('sylius.mongodb_odm.repository.class');
     if (isset($classes['repository'])) {
         $repositoryClass = $classes['repository'];
     }
     $unitOfWorkDefinition = new Definition('Doctrine\\ODM\\MongoDB\\UnitOfWork');
     $unitOfWorkDefinition->setFactoryService($this->getManagerServiceKey())->setFactoryMethod('getUnitOfWork')->setPublic(false);
     $definition = new Definition($repositoryClass);
     $definition->setArguments(array(new Reference($this->getContainerKey('manager')), $unitOfWorkDefinition, $this->getClassMetadataDefinition($classes['model'])));
     return $definition;
 }
开发者ID:aleherse,项目名称:Sylius,代码行数:18,代码来源:DoctrineODMDriver.php


注:本文中的Symfony\Component\DependencyInjection\Definition::setFactoryService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。