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


PHP Container::findByTag方法代码示例

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


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

示例1: createPresenter

 /**
  * Creates new presenter instance.
  *
  * @param  string presenter class name
  * @return Application\IPresenter
  */
 public function createPresenter($class)
 {
     $callInjects = $this->alwaysCallInjects;
     $services = array_keys($this->container->findByTag('nette.presenter'), $class);
     if (count($services) > 1) {
         throw new Application\InvalidPresenterException("Multiple services of type {$class} found: " . implode(', ', $services) . '.');
     } elseif (count($services)) {
         $presenter = $this->container->createService($services[0]);
         $callInjects = FALSE;
     } elseif (count($services = $this->container->findByType($class)) === 1) {
         $presenter = $this->container->createService($services[0]);
     } else {
         $presenter = $this->container->createInstance($class);
         $callInjects = TRUE;
     }
     if (!$presenter instanceof Application\IPresenter) {
         throw new UnexpectedValueException("Unable to create create presenter, returned value is not Nette\\Application\\IPresenter type.");
     }
     if ($callInjects) {
         $this->container->callInjects($presenter);
     }
     if ($presenter instanceof Application\UI\Presenter && $presenter->invalidLinkMode === NULL) {
         $presenter->invalidLinkMode = $this->invalidLinkMode;
     }
     return $presenter;
 }
开发者ID:librette,项目名称:presenter-factory,代码行数:32,代码来源:PresenterObjectFactory.php

示例2: __construct

 public function __construct(Container $container)
 {
     $this->connections = array_keys($container->findByTag(OrmExtension::TAG_CONNECTION));
     $this->defaultConnection = $container->findByType('Doctrine\\DBAL\\Connection');
     $this->managers = array_keys($container->findByTag(OrmExtension::TAG_ENTITY_MANAGER));
     $this->defaultManager = $container->findByType('Doctrine\\ORM\\EntityManager');
     $this->container = $container;
 }
开发者ID:chiriacbogdan,项目名称:Doctrine,代码行数:8,代码来源:ManagerRegistry.php

示例3: create

 /**
  * @return MapperMatrix
  */
 public function create()
 {
     $matrix = new MapperMatrix();
     foreach ($this->container->findByTag('echo511.leanmapper.mapper') as $serviceName => $tagAttributes) {
         $matrix->addMapper($this->container->getService($serviceName));
     }
     return $matrix;
 }
开发者ID:echo511,项目名称:leanmapper,代码行数:11,代码来源:MapperMatrixFactory.php

示例4: create

 public function create() : Registry
 {
     $tagToService = function (array $tags) {
         return array_map(function (string $serviceName) {
             return $this->container->getService($serviceName);
         }, array_keys($tags));
     };
     return new Registry($tagToService($this->container->findByTag(self::RULE_TAG)));
 }
开发者ID:phpstan,项目名称:phpstan,代码行数:9,代码来源:RegistryFactory.php

示例5: create

 public function create() : Broker
 {
     $tagToService = function (array $tags) {
         return array_map(function (string $serviceName) {
             return $this->container->getService($serviceName);
         }, array_keys($tags));
     };
     $phpClassReflectionExtension = $this->container->getByType(PhpClassReflectionExtension::class);
     return new Broker(array_merge([$phpClassReflectionExtension], $tagToService($this->container->findByTag(self::PROPERTIES_CLASS_REFLECTION_EXTENSION_TAG))), array_merge([$phpClassReflectionExtension], $tagToService($this->container->findByTag(self::METHODS_CLASS_REFLECTION_EXTENSION_TAG))), $tagToService($this->container->findByTag(self::DYNAMIC_METHOD_RETURN_TYPE_EXTENSION_TAG)), $this->container->getByType(FunctionReflectionFactory::class));
 }
开发者ID:phpstan,项目名称:phpstan,代码行数:10,代码来源:BrokerFactory.php

示例6: getSections

 /**
  * @return TargetSection[]
  * @throws \Nette\InvalidStateException
  */
 public function getSections()
 {
     $sections = array();
     foreach ($this->container->findByTag("Brabijan.seo.targetSectionProvider") as $serviceName => $attributes) {
         $section = $this->container->getService($serviceName);
         if (!$section instanceof ITargetSectionProvider) {
             throw new InvalidStateException('Target provider must be instance of Brabijan\\SeoComponents\\DI\\ITargetSectionProvider');
         }
         $sections[] = $section->getTargetSection();
     }
     return $sections;
 }
开发者ID:brabijan,项目名称:nette-seo-components,代码行数:16,代码来源:AllowedTargetList.php

示例7: create

 public function create()
 {
     $serviceNames = $this->context->findByTag($this->tagName);
     $jobs = array();
     foreach ($serviceNames as $name => $attrs) {
         $job = $this->context->getService($name);
         if (!$job instanceof IJob) {
             throw new \InvalidArgumentException("Service {$name} must implements Cron\\IJob interface!");
         }
         $jobs[] = $job;
     }
     return new Cron($jobs);
 }
开发者ID:foowie,项目名称:cron,代码行数:13,代码来源:ContextCronFactory.php

示例8: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (defined('AMQP_DEBUG') === false) {
         define('AMQP_DEBUG', (bool) $input->getOption('debug'));
     }
     $output->writeln('Setting up the Rabbit MQ fabric');
     foreach (array(RabbitMqExtension::TAG_PRODUCER, RabbitMqExtension::TAG_CONSUMER, RabbitMqExtension::TAG_RPC_CLIENT, RabbitMqExtension::TAG_RPC_SERVER) as $tag) {
         foreach ($this->container->findByTag($tag) as $serviceId => $meta) {
             /** @var AmqpMember $service */
             $service = $this->container->getService($serviceId);
             $service->setupFabric();
         }
     }
 }
开发者ID:petrnemec,项目名称:RabbitMq,代码行数:14,代码来源:SetupFabricCommand.php

示例9: __invoke

 /**
  * @return Nette\Application\IPresenter
  */
 public function __invoke($class)
 {
     $services = array_keys($this->container->findByTag('nette.presenter'), $class);
     if (count($services) > 1) {
         throw new Nette\Application\InvalidPresenterException("Multiple services of type {$class} found: " . implode(', ', $services) . '.');
     } elseif (!$services) {
         if ($this->touchToRefresh) {
             touch($this->touchToRefresh);
         }
         $presenter = $this->container->createInstance($class);
         $this->container->callInjects($presenter);
         if ($presenter instanceof Nette\Application\UI\Presenter && $presenter->invalidLinkMode === NULL) {
             $presenter->invalidLinkMode = $this->invalidLinkMode;
         }
         return $presenter;
     }
     return $this->container->createService($services[0]);
 }
开发者ID:Richmond77,项目名称:learning-nette,代码行数:21,代码来源:PresenterFactoryCallback.php

示例10: createRouter

 /**
  * @param Nette\DI\Container $di
  *
  * @return Nette\Application\IRouter
  */
 public static function createRouter(Nette\DI\Container $di)
 {
     $router = new Nette\Application\Routers\RouteList();
     foreach ($di->findByTag('router') as $name => $hasTag) {
         if ($hasTag) {
             $router[] = $di->getService($name);
         }
     }
     return $router;
 }
开发者ID:sw2eu,项目名称:hotplug,代码行数:15,代码来源:RouterFactory.php

示例11: createConsole

 /**
  * @param Container
  * @return Application
  */
 public static function createConsole(Container $container, $config)
 {
     $console = new Application($config['name'], $config['version']);
     $helperSet = new HelperSet();
     foreach (array_keys($container->findByTag(self::HELPER_TAG)) as $name) {
         $helperSet->set($container->getService($name), $name);
     }
     $console->setHelperSet($helperSet);
     $console->setCatchExceptions($config['catchExceptions']);
     $commands = [];
     foreach (array_keys($container->findByTag(self::COMMAND_TAG)) as $name) {
         $commands[] = $container->getService($name);
     }
     foreach (array_keys($container->findByTag(self::KDYBY_COMMAND_TAG)) as $name) {
         $commands[] = $container->getService($name);
     }
     $console->addCommands($commands);
     return $console;
 }
开发者ID:bazo,项目名称:nette-console-extension,代码行数:23,代码来源:ConsoleExtension.php

示例12: createPresenter

 /**
  * Creates new presenter instance.
  * @param  string  presenter name
  * @return IPresenter
  */
 public function createPresenter($name)
 {
     $class = $this->getPresenterClass($name);
     $services = array_keys($this->container->findByTag('nette.presenter'), $class);
     if (count($services) > 1) {
         throw new InvalidPresenterException("Multiple services of type {$class} found: " . implode(', ', $services) . '.');
     } elseif (!$services) {
         if ($this->autoRebuild) {
             $rc = new \ReflectionClass($this->container);
             @unlink($rc->getFileName());
             // @ file may not exists
         }
         $presenter = $this->container->createInstance($class);
         $this->container->callInjects($presenter);
         if ($presenter instanceof UI\Presenter && $presenter->invalidLinkMode === NULL) {
             $presenter->invalidLinkMode = $this->container->parameters['debugMode'] ? UI\Presenter::INVALID_LINK_WARNING : UI\Presenter::INVALID_LINK_SILENT;
         }
         return $presenter;
     }
     return $this->container->createService($services[0]);
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:26,代码来源:PresenterFactory.php

示例13: findConsumer

 /**
  * @param string $routingKey
  * @return Kdyby\RabbitMq\Consumer
  */
 private function findConsumer($routingKey)
 {
     foreach ($this->serviceLocator->findByTag(RabbitMqExtension::TAG_CONSUMER) as $consumerService => $_) {
         /** @var Kdyby\RabbitMq\Consumer $consumer */
         $consumer = $this->serviceLocator->getService($consumerService);
         if ($consumer instanceof Kdyby\RabbitMq\MultipleConsumer) {
             continue;
             // todo: not yet implemented
         }
         if ($consumer->exchangeOptions['name'] !== $this->exchangeOptions['name']) {
             continue;
             // nope
         }
         if (empty($routingKey)) {
             return $consumer;
         }
         continue;
         // todo: not yet implemented
     }
     return NULL;
 }
开发者ID:fprochazka,项目名称:posobota-rabbitmq-workshop-01-2016,代码行数:25,代码来源:RabbitProducerMock.php

示例14: createConsole

 /**
  * @param \Nette\DI\Container
  * @param \Symfony\Component\Console\Helper\HelperSet
  * @return \Symfony\Component\Console\Application
  */
 public static function createConsole(\Nette\DI\Container $container, \Symfony\Component\Console\Helper\HelperSet $helperSet = NULL)
 {
     $console = new \Symfony\Component\Console\Application(Framework::NAME . " Command Line Interface", Framework::VERSION);
     if (!$helperSet) {
         $helperSet = new \Symfony\Component\Console\Helper\HelperSet();
         $helperSet->set(new \Doctrine\ODM\MongoDB\Tools\Console\Helper\DocumentManagerHelper($container->documentManager), 'dm');
         $helperSet->set(new \Symfony\Component\Console\Helper\DialogHelper(), 'dialog');
     }
     $console->setHelperSet($helperSet);
     $console->setCatchExceptions(FALSE);
     $commands = array();
     foreach (array_keys($container->findByTag('consoleCommand')) as $name) {
         $commands[] = $container->getService($name);
     }
     $console->addCommands($commands);
     return $console;
 }
开发者ID:jango2015,项目名称:nette-mongodb-sandbox,代码行数:22,代码来源:ConsoleExtension.php

示例15: setupEventManager

 /**
  * @param \Doctrine\Common\EventManager
  * @param \Nette\DI\Container
  */
 public static function setupEventManager(EventManager $evm, Container $container)
 {
     foreach ($container->findByTag(static::EVENT_TAG_NAME) as $name => $value) {
         $evm->addEventSubscriber($container->getService($name));
     }
 }
开发者ID:snake-aas,项目名称:doctrine,代码行数:10,代码来源:Extension.php


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