本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::findTags方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::findTags方法的具体用法?PHP ContainerBuilder::findTags怎么用?PHP ContainerBuilder::findTags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::findTags方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testServicesDefinitionTest
public function testServicesDefinitionTest()
{
$this->createFullConfiguration();
$tags = $this->configuration->findTags();
$this->assertEquals('form.type', $tags[0]);
$taggedServices = $this->configuration->findTaggedServiceIds($tags[0]);
$this->assertTrue(isset($taggedServices['acme_cart.cart.form.type']));
$this->assertEquals('leaphly_cart', $taggedServices['acme_cart.cart.form.type'][0]['alias']);
$this->assertTrue(isset($taggedServices['acme_cart.cart.limited.form.type']));
$this->assertEquals('leaphly_cart_limited', $taggedServices['acme_cart.cart.limited.form.type'][0]['alias']);
}
示例2: outputTags
/**
* Renders list of tagged services grouped by tag.
*
* @param OutputInterface $output
* @param bool $showPrivate
*/
protected function outputTags(OutputInterface $output, $showPrivate = false)
{
$tags = $this->containerBuilder->findTags();
asort($tags);
$label = 'Tagged services';
$output->writeln($this->getHelper('formatter')->formatSection('container', $label));
foreach ($tags as $tag) {
$serviceIds = $this->containerBuilder->findTaggedServiceIds($tag);
foreach ($serviceIds as $serviceId => $attributes) {
$definition = $this->resolveServiceDefinition($serviceId);
if ($definition instanceof Definition) {
if (!$showPrivate && !$definition->isPublic()) {
unset($serviceIds[$serviceId]);
continue;
}
}
}
if (count($serviceIds) === 0) {
continue;
}
$output->writeln($this->getHelper('formatter')->formatSection('tag', $tag));
foreach ($serviceIds as $serviceId => $attributes) {
$output->writeln($serviceId);
}
$output->writeln('');
}
}
示例3: process
public function process(ContainerBuilder $container)
{
$compiler = $container->getCompiler();
$formatter = $compiler->getLoggingFormatter();
$tags = array_unique(array_merge($container->findTags(), $this->whitelist));
foreach ($container->findUnusedTags() as $tag) {
// skip whitelisted tags
if (in_array($tag, $this->whitelist)) {
continue;
}
// check for typos
$candidates = array();
foreach ($tags as $definedTag) {
if ($definedTag === $tag) {
continue;
}
if (false !== strpos($definedTag, $tag) || levenshtein($tag, $definedTag) <= strlen($tag) / 3) {
$candidates[] = $definedTag;
}
}
$services = array_keys($container->findTaggedServiceIds($tag));
$message = sprintf('Tag "%s" was defined on service(s) "%s", but was never used.', $tag, implode('", "', $services));
if (!empty($candidates)) {
$message .= sprintf(' Did you mean "%s"?', implode('", "', $candidates));
}
$compiler->addLogMessage($formatter->format($this, $message));
}
}
示例4: addCustom
protected function addCustom($options)
{
$tags = array();
foreach ($this->container->findTags() as $tag) {
$tags[$tag] = array_keys($this->container->findTaggedServiceIds($tag));
}
$configurations = array();
$disabled = array();
foreach ($options['nucleus']['services'] as $serviceName => $serviceDefinition) {
$configurations[$serviceName] = null;
if (isset($serviceDefinition['disabled']) && $serviceDefinition['disabled']) {
$disabled[] = $serviceName;
}
if (isset($serviceDefinition['configuration'])) {
$configurations[$serviceName] = $serviceDefinition['configuration'];
}
}
return '
protected $tags = ' . var_export($tags, true) . ';
protected $disabled = ' . var_export($disabled, true) . ';
';
}
示例5: findDefinitionsByTag
/**
* @param ContainerBuilder $builder
* @param bool $showPrivate
*
* @return array
*/
protected function findDefinitionsByTag(ContainerBuilder $builder, $showPrivate)
{
$definitions = array();
$tags = $builder->findTags();
asort($tags);
foreach ($tags as $tag) {
foreach ($builder->findTaggedServiceIds($tag) as $serviceId => $attributes) {
$definition = $this->resolveServiceDefinition($builder, $serviceId);
if (!$definition instanceof Definition || !$showPrivate && !$definition->isPublic()) {
continue;
}
if (!isset($definitions[$tag])) {
$definitions[$tag] = array();
}
$definitions[$tag][$serviceId] = $definition;
}
}
return $definitions;
}
示例6: findTags
/**
* Returns all tags the defined services use.
*
* @return array An array of tags
*
* @api
* @since 4.0.0
*/
public function findTags()
{
return $this->_delegateContainerBuilder->findTags();
}