/** * @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; }
/** * 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)); }
/** * @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'); }
/** * 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); }