本文整理汇总了PHP中Symfony\Component\DependencyInjection\Definition::getTag方法的典型用法代码示例。如果您正苦于以下问题:PHP Definition::getTag方法的具体用法?PHP Definition::getTag怎么用?PHP Definition::getTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\Definition
的用法示例。
在下文中一共展示了Definition::getTag方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFormName
/**
* @param Definition $formDefinition
*
* @return string Form name
*/
private function getFormName(Definition $formDefinition)
{
$tags = $formDefinition->getTag('form.type');
$formName = isset($tags[0]['alias']) ? $tags[0]['alias'] : null;
if (null === $formName) {
throw new \InvalidArgumentException(sprintf('Definition "%s" tagged by "%s" should also be tagged by "%s" with attribute "%s"', $formDefinition->getClass(), 'sylius.metadata.dynamic_form', 'form.type', 'alias'));
}
return $formName;
}
示例2: getServiceDocument
/**
* Get document class name from service
*
* @param Definition $service Service definition
* @param string $ns Bundle namespace
* @param string $bundle Bundle name
* @param string $doc Document name
* @return string
*/
private function getServiceDocument(Definition $service, $ns, $bundle, $doc)
{
$tags = $service->getTag('graviton.rest');
if (!empty($tags[0]['collection'])) {
$doc = $tags[0]['collection'];
$bundle = $tags[0]['collection'];
}
if (strtolower($ns) === 'gravitondyn') {
$ns = 'GravitonDyn';
}
return sprintf('%s\\%s\\Document\\%s', ucfirst($ns), ucfirst($bundle) . 'Bundle', ucfirst($doc));
}
示例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: getTag
/**
* Get a tag by name.
*
* @param string $name The tag name
*
* @return array An array of attributes
*
* @api
* @since 4.0.0
*/
public function getTag($name)
{
return $this->_underlyingSymfonyDefinition->getTag($name);
}