Skip to content

Commit

Permalink
Added Yaml syntax shortcut for name-only tags
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed Nov 27, 2016
1 parent ea7e245 commit 7fa8c8a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
Expand Up @@ -267,7 +267,7 @@ private function parseDefinition($id, $service, $file)

foreach ($service['tags'] as $tag) {
if (!is_array($tag)) {
throw new InvalidArgumentException(sprintf('A "tags" entry must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file));
$tag = array('name' => $tag);
}

if (!isset($tag['name'])) {
Expand Down

This file was deleted.

@@ -0,0 +1,5 @@
services:
foo_service:
class: FooClass
tags:
- foo
Expand Up @@ -223,16 +223,6 @@ public function testNonArrayTagsThrowsException()
}
}

/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
* @expectedExceptionMessage A "tags" entry must be an array for service
*/
public function testNonArrayTagThrowsException()
{
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load('badtag4.yml');
}

public function testTagWithoutNameThrowsException()
{
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
Expand All @@ -245,6 +235,15 @@ public function testTagWithoutNameThrowsException()
}
}

public function testNameOnlyTagsAreAllowedAsString()
{
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load('tag_name_only.yml');

$this->assertCount(1, $container->getDefinition('foo_service')->getTag('foo'));
}

public function testTagWithAttributeArrayThrowsException()
{
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
Expand Down

0 comments on commit 7fa8c8a

Please sign in to comment.