當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ContainerBuilder::findByTag方法代碼示例

本文整理匯總了PHP中Nette\DI\ContainerBuilder::findByTag方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContainerBuilder::findByTag方法的具體用法?PHP ContainerBuilder::findByTag怎麽用?PHP ContainerBuilder::findByTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nette\DI\ContainerBuilder的用法示例。


在下文中一共展示了ContainerBuilder::findByTag方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: beforeCompile

 public function beforeCompile()
 {
     $config = $this->getConfig($this->defaults);
     $cacheDirectory = $config['cacheDir'] . "/";
     $tag = $this->prefix(static::LAZY);
     if ($config['autogenerateProxyClasses']) {
         foreach (array_keys($this->builder->findByTag($tag)) as $serviceName) {
             $this->createLazyProxy($serviceName);
         }
     } else {
         $this->proxyGenerator = new LazyLoadingValueHolderGenerator();
         foreach (array_keys($this->builder->findByTag($tag)) as $serviceName) {
             $this->createEagerProxy($serviceName, $cacheDirectory);
         }
     }
 }
開發者ID:radekdvorak,項目名稱:nette-proxy-service,代碼行數:16,代碼來源:ProxyServiceExtension.php

示例2: getSortedConfigurators

 /**
  * @param ContainerBuilder $builder
  * @return array
  */
 private function getSortedConfigurators(ContainerBuilder $builder)
 {
     $configurators = $builder->findByTag(self::TAG_CONFIGURATOR);
     uasort($configurators, function ($a, $b) {
         $a = is_numeric($a) ? (double) $a : 0;
         $b = is_numeric($b) ? (double) $b : 0;
         return $a < $b ? -1 : ($a > $b ? 1 : 0);
     });
     return $configurators;
 }
開發者ID:lookyman,項目名稱:nette-texy,代碼行數:14,代碼來源:TexyExtension.php

示例3: createSubscribersMap

 private function createSubscribersMap(\Nette\DI\ContainerBuilder $builder)
 {
     $map = [];
     foreach ($builder->findByTag(self::TAG_SUBSCRIBER) as $serviceName => $tagProperties) {
         $def = $builder->getDefinition($serviceName);
         $class = $def->getClass();
         $events = $class::getSubscribedEvents();
         foreach ($events as $eventName => $callbacks) {
             foreach ($callbacks as $function) {
                 $map[$eventName][] = [$serviceName, $function];
             }
         }
     }
     return $map;
 }
開發者ID:bazo,項目名稱:nette-events-extension,代碼行數:15,代碼來源:EventsExtension.php

示例4: findRoutes

 /**
  * @param  Nette\DI\ContainerBuilder $builder
  * @return array
  */
 private function findRoutes(Nette\DI\ContainerBuilder $builder)
 {
     /**
      * Find all presenters and their routes
      */
     $presenters = $builder->findByTag('nette.presenter');
     $routes = [];
     foreach ($presenters as $presenter) {
         $this->findRoutesInPresenter($presenter, $routes);
     }
     /**
      * Return routes sorted by priority
      */
     return $this->sortByPriority($routes);
 }
開發者ID:ublaboo,項目名稱:api-router,代碼行數:19,代碼來源:ApiRouterExtension.php

示例5: registerWidgets

 private function registerWidgets(ContainerBuilder $builder)
 {
     $widgets = $builder->getDefinition($this->prefix('widgets'));
     foreach (array_keys($builder->findByTag(self::WIDGET_TAG)) as $widget) {
         $definition = $builder->getDefinition($widget);
         if (!isset($definition->tags['name'])) {
             throw new InvalidArgumentException('Missing name for widget ' . $widget);
         }
         $name = $definition->tags['name'];
         $widgets->addSetup('addWidget', [$name, '@' . $widget]);
     }
 }
開發者ID:peterzadori,項目名稱:movi,代碼行數:12,代碼來源:moviExtension.php

示例6: buildAuthorizatorList

 /**
  * @param \Nette\DI\ContainerBuilder $builder
  */
 private function buildAuthorizatorList(ContainerBuilder $builder)
 {
     $services = [];
     foreach ($builder->findByTag($this->prefix(self::AUTHORIZATOR_TAG)) as $name => $priority) {
         if (!Validators::isNumericInt($priority)) {
             throw new \Nette\InvalidArgumentException(sprintf('Authorizator priority for service %s has to be integer, %s given.', $name, gettype($priority)));
         }
         $services[(int) $priority][] = $name;
     }
     krsort($services);
     return iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($services)), FALSE);
 }
開發者ID:ark8,項目名稱:security,代碼行數:15,代碼來源:SecurityExtension.php

示例7: afterCompile

 function afterCompile(ContainerBuilder $container, Nette\Utils\PhpGenerator\ClassType $class)
 {
     $initialize = $class->methods['initialize'];
     if (isset($container->parameters['tempDir'])) {
         $initialize->addBody($this->checkTempDir($container->expand($container->parameters['tempDir'])));
     }
     foreach ($container->findByTag('run') as $name => $foo) {
         $initialize->addBody('$this->getService(?);', array($name));
     }
 }
開發者ID:skapytek,項目名稱:scripts,代碼行數:10,代碼來源:nette.min.php


注:本文中的Nette\DI\ContainerBuilder::findByTag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。