We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi!
I'm facing an issue related to #3451
Consider the following example:
class SomeExtension extends AbstractExtension { private array $filters = [ 'filter1', 'filter2', 'filter3', // and so on... ]; public function getFilters(): array { $filters = []; foreach ($this->filters as $filter) { $filters[] = new TwigFilter( $filter, [SomeRuntime::class, $filter], // Don't work // ["SomeRuntime::$filter"], // Don't work either ['is_variadic' => true] ); } return $filters; } } class SomeRuntime implements RuntimeExtensionInterface { private Service $service; public function __construct(Service $service) { $this->service = $service; } public function __call($name, array $arguments = []) { $object = $this->service->create($arguments[0]); return $object->$name(...$arguments) } }
Note that in my real world example, I make use of the ContainerRuntimeLoader to inject Service in my runtime but I don't think it's relevant here.
ContainerRuntimeLoader
Service
Sadly you can't use __call in a RuntimeExtensionInterface because of
__call
RuntimeExtensionInterface
Twig/src/Node/Expression/CallExpression.php
Lines 296 to 299 in 8717478
Whereas this approach works fine if I use a regular AbstractExtension, not a RuntimeExtensionInterface extension.
AbstractExtension
It would be great that runtime extension handles this use case too.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi!
I'm facing an issue related to #3451
Consider the following example:
Note that in my real world example, I make use of the
ContainerRuntimeLoader
to injectService
in my runtime but I don't think it's relevant here.Sadly you can't use
__call
in aRuntimeExtensionInterface
because ofTwig/src/Node/Expression/CallExpression.php
Lines 296 to 299 in 8717478
Whereas this approach works fine if I use a regular
AbstractExtension
, not aRuntimeExtensionInterface
extension.It would be great that runtime extension handles this use case too.
The text was updated successfully, but these errors were encountered: