本文整理汇总了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);
}
}
}
示例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;
}
示例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;
}
示例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);
}
示例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]);
}
}
示例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);
}
示例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));
}
}