What's the smallest syntax for tagged service (NEON)

Tomáš Votruba
Moderator | 1154
+
0
-

Tagging service in config.neon:

-
    class: App\CatalogModule\Filters\LocaleFilter
    tags: [zenify.doctrine.filter]

With this commit, we can drop 1 line:

- class: App\CatalogModule\Filters\LocaleFilter
  tags: [zenify.doctrine.filter]

Is there anything shorter than this?

jiri.pudil
Member | 861
+
+2
-

You can go with this one-liner, but it affects readability (and it's not much shorter actually):

- {class: App\CatalogModule\Filters\LocaleFilter, tags: [zenify.doctrine.filter]}

Comments

hrach:

I use this too. It's more readable :)

5 years ago
Tomáš Votruba:

Nice. Seems more readable for me as well.

5 years ago
enumag
Member | 2128
+
-1
-

I don't know anything shorter for one service. However if you have multiple services implementing same interface that should have the same tag, you cen use TemplateExtension from dev Nette.

Comments

Tomáš Votruba:

@enumag Looks like that didn't get into dev nette (commit), did it?

TemplateExtension source seems like temporary solution for me.

@matej21 I'd prefer native Nette solution. If that doesn't work, I'll check your library. Thanks

5 years ago