Open tacman opened 4 months ago
If we have to add a compiler pass, why don't do something to properly inject the configured service for the namer? So, we can make all the namers private again.
To elaborate a bit on my previous comment: I was thinking about injecting two services into PropertyMappingResolver, a NamerInterface
and an optional DirectoryNamerInterface
.
The definition would be empty in the service configuration, and the compiler pass should resolve these two services.
PRs are welcome.
A directory namer would be cool. In fact, my custom namer really is only the directory.
$file = $mapping->getFile($object);
$name = $file->getClientOriginalName();
/** @var $object Project|Asset */
$name = match ($object::class) {
Project::class => sprintf("%s/%s", $object->getSlug(), $name),
Asset::class => sprintf("%s/%s/%s", $object->getProject()->getSlug(), $object->getItem()->getCode(), $name),
};
return $name;
Feature Request
Summary
Instead or requiring namer services to be manually registered.
The compiler pass could look for services that implement NamerInterface and make them public. One less step when creating a custom namer service.