Issue 1:
Q
A

Bug report?
no

Feature request?
yes

BC Break report?
no

RFC?
yes

Symfony version
4.1

Still being on 3.3, my first preparation in my application is to change everything to autowiring. Now that we have autoconfigure and resource loading, it's a lot easier to get things started with ~1900 services in my app.

However, there are some obstacles I'm hitting that still require me to define a lot of services in my config. While we can currently already use !tagged to avoid using compiler passes in 3.4, I'm still required to configure a priority when this is needed. In some cases, I have ~20 service definitions that I need to sort and inject into another.

Now my autowire.yml looks something like this:

services:
#...
App\Option\One:
tags:
- { name: app.option, priority: 10 }
- { name: features.tag, tag: some_feature_name }
App\Option\Two: { tags: [{name: app.option, priority: 15}] }
App\Option\Three: { tags: [{name: app.option, priority: 100}] }
App\Option\Four: { tags: [{name: app.option, priority: -10}] }

App\Feature\EnvironmentResolver:
tags: [{ name: features.resolver, config-key: environment }]
#...

Ideally I'd only define the service definition that collects these options, so I've been wondering if a tag subscriber would be the solution. Similar to event listeners vs event subscribers, this would allow a class to subscribe to specific tags, which can be picked up by autoconfigure:

interface TagSubscriberInterface
{
public static function getTags(): array;
}

final class One implements OptionInterface, TagSubscriberInterface
{
// ...
public static function getTags()
{
// multiple tags
return [
['name' => 'app.option', 'priority' => 10],
['name' => 'features.tag', 'tag' => 'some_feature_name'],
];
// different style in case of single tag
return ['name' => 'app.option', 'priority' => 10];
}
}

final class EnvironmentResolver implements FeatureResolverInterface, TagSubscriberInterface
{
// ...
public static function getTags()
{
return ['name' => 'features.resolver', 'config-key' => 'environment'];
}
}

WDYT?

@Simperfit 😄

Issue 2:
Q
A

Bug report?
yes

Feature request?
no

BC Break report?
yes

RFC?
no

Symfony version
3.1.8

On our application we're using in some places the twig namespace syntax (@namespace/folder1/template.html.twig) and in templates that uses embed twig uses the SF TemplateReference to get the logical name which leads to the SF syntax (Bundle:folder1:template.html.twig).

What happens is that twig loader loads @namespace/folder1/template.html.twig but fails on Bundle:folder1:template.html.twig then SF filesystem loader is used as fallback. The problem is that twig loader uses realpath() since v1.27 and SF loader doesn't.

I've solved that on our application by overriding SF loader and using realpath() as well but although it works fine I'm not 100% sure if that's the way to go (that's why I didn't send a PR):

use Symfony\Bundle\TwigBundle\Loader\FilesystemLoader;

final class TemplateLoader extends FilesystemLoader
{
protected function findTemplate($template, $throw = true)
{
$file = parent::findTemplate($template, $throw);

if ($absolutePath = realpath($file)) {
$file = $absolutePath;
}

return $this->cache[(string) $template] = $file;
}
}