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


PHP Definition::hasTag方法代码示例

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


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

示例1: array

 function it_should_get_interfaces(ContainerBuilder $container, Definition $resolverDefinition)
 {
     $resolverDefinition->hasTag('doctrine.event_listener')->shouldBeCalled()->willReturn(false);
     $resolverDefinition->addTag('doctrine.event_listener', array('event' => 'loadClassMetadata'))->shouldBeCalled();
     $container->hasDefinition('doctrine.orm.listeners.resolve_target_entity')->shouldBeCalled()->willReturn(true);
     $container->findDefinition('doctrine.orm.listeners.resolve_target_entity')->shouldBeCalled()->willReturn($resolverDefinition);
     $container->hasParameter(RepositoryInterface::class)->shouldBeCalled()->willReturn(false);
     $container->hasParameter('spec\\Sylius\\Bundle\\ResourceBundle\\Fixture\\Entity\\Foo')->shouldBeCalled()->willReturn(false);
     $resolverDefinition->addMethodCall('addResolveTargetEntity', array(RepositoryInterface::class, 'spec\\Sylius\\Bundle\\ResourceBundle\\Fixture\\Entity\\Foo', array()))->shouldBeCalled();
     $this->resolve($container, array(RepositoryInterface::class => 'spec\\Sylius\\Bundle\\ResourceBundle\\Fixture\\Entity\\Foo'));
 }
开发者ID:Silwereth,项目名称:Sylius,代码行数:11,代码来源:DoctrineTargetEntitiesResolverSpec.php

示例2:

 function it_should_get_interfaces(ContainerBuilder $container, Definition $resolverDefinition)
 {
     $resolverDefinition->hasTag('doctrine.event_listener')->willReturn(false);
     $resolverDefinition->addTag('doctrine.event_listener', ['event' => 'loadClassMetadata'])->shouldBeCalled();
     $container->hasDefinition('doctrine.orm.listeners.resolve_target_entity')->willReturn(true);
     $container->findDefinition('doctrine.orm.listeners.resolve_target_entity')->willReturn($resolverDefinition);
     $container->hasParameter(RepositoryInterface::class)->willReturn(false);
     $container->hasParameter(Foo::class)->willReturn(false);
     $resolverDefinition->addMethodCall('addResolveTargetEntity', [RepositoryInterface::class, Foo::class, []])->shouldBeCalled();
     $this->resolve($container, [RepositoryInterface::class => Foo::class]);
 }
开发者ID:benakacha,项目名称:Sylius,代码行数:11,代码来源:DoctrineTargetEntitiesResolverSpec.php

示例3: testTags

 /**
  * @covers Symfony\Component\DependencyInjection\Definition::addTag
  * @covers Symfony\Component\DependencyInjection\Definition::getTag
  * @covers Symfony\Component\DependencyInjection\Definition::getTags
  * @covers Symfony\Component\DependencyInjection\Definition::hasTag
  */
 public function testTags()
 {
     $def = new Definition('stdClass');
     $this->assertEquals(array(), $def->getTag('foo'), '->getTag() returns an empty array if the tag is not defined');
     $this->assertFalse($def->hasTag('foo'));
     $this->assertSame($def, $def->addTag('foo'), '->addTag() implements a fluent interface');
     $this->assertTrue($def->hasTag('foo'));
     $this->assertEquals(array(array()), $def->getTag('foo'), '->getTag() returns attributes for a tag name');
     $def->addTag('foo', array('foo' => 'bar'));
     $this->assertEquals(array(array(), array('foo' => 'bar')), $def->getTag('foo'), '->addTag() can adds the same tag several times');
     $def->addTag('bar', array('bar' => 'bar'));
     $this->assertEquals($def->getTags(), array('foo' => array(array(), array('foo' => 'bar')), 'bar' => array(array('bar' => 'bar'))), '->getTags() returns all tags');
 }
开发者ID:nuwe1,项目名称:symfony,代码行数:19,代码来源:DefinitionTest.php

示例4: hasTag

 /**
  * Check whether this definition has a tag with the given name
  *
  * @param string $name The name of the tag
  *
  * @return Boolean
  *
  * @api
  * @since 4.0.0
  */
 public function hasTag($name)
 {
     return $this->_underlyingSymfonyDefinition->hasTag($name);
 }
开发者ID:tubepress,项目名称:tubepress,代码行数:14,代码来源:Definition.php

示例5: assertTaggedServiceIsFormType

 /**
  * @param Definition $formType
  * @param string     $serviceId
  *
  * @throws \InvalidArgumentException
  */
 public function assertTaggedServiceIsFormType(Definition $formType, $serviceId)
 {
     if (!$formType->hasTag('form.type')) {
         throw new \InvalidArgumentException(sprintf('Service with id "%s" has to be tagged with "form.type".', $serviceId));
     }
 }
开发者ID:ClearcodeHQ,项目名称:command-bus-console,代码行数:12,代码来源:RegisterConsoleCommandsCompilerPass.php

示例6: tryHydrateDefinitionForRestoration

 /**
  * @param string     $id
  * @param Definition $definition
  * @param array      $definitionArray
  */
 private function tryHydrateDefinitionForRestoration($id, Definition $definition, array &$definitionArray)
 {
     if ($this->container->isLoaded($id) && $definition->hasTag('dumpable')) {
         $service = $this->container->get($id);
         if (!$service instanceof DumpableServiceInterface) {
             throw new ServiceNotDumpableException($id, get_class($service));
         }
         $classProxy = $service->getClassProxy() ?: get_class($service);
         if (!in_array(self::RESTORABLE_SERVICE_INTERFACE, class_implements($classProxy))) {
             throw new InvalidServiceProxyException($classProxy);
         }
         if (isset($definitionArray['class'])) {
             if ($classProxy !== $definitionArray['class']) {
                 unset($definitionArray['arguments']);
             }
             $definitionArray['class'] = $classProxy;
         }
         unset($definitionArray['configurator']);
         $definitionArray['calls'] = [];
         $definitionArray['calls'][] = ['restore', ['@service_container', $service->dump()]];
     }
 }
开发者ID:mickaelsteinberg,项目名称:BackBee,代码行数:27,代码来源:PhpArrayDumper.php


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