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