-
-
Notifications
You must be signed in to change notification settings - Fork 956
Closed
Description
After updating to v2.4.3 I started getting Unused binding "$requestStack" in service "Extended\From\AbstractFilter\MyFilter" error.
Here is my config:
_defaults:
autowire: true
autoconfigure: true
public: false
Extended\From\AbstractFilter\MyFilter:
arguments:
$managerRegistry: '@doctrine'
$myParam: 'value'
tags:
- { name: 'api_platform.filter', id: 'my_filter' }And the filter pseudocode:
<?php
namespace Extended\From\AbstractFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\AbstractFilter;
use Doctrine\ORM\QueryBuilder;
use Psr\Log\LoggerInterface;
use Symfony\Bridge\Doctrine\ManagerRegistry;
class MyFilter extends AbstractFilter
{
/** @var string */
private $myParam;
public function __construct(ManagerRegistry $managerRegistry, LoggerInterface $logger = null, string $myParam)
{
parent::__construct($managerRegistry, null, $logger);
$this->myParam = $myParam;
}
public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null)
{
//handle
}
public function getDescription(string $resourceClass): array
{
return [];
}
}I was able to fix the error by switching off autowire and autoconfigure for the service:
Extended\From\AbstractFilter\MyFilter:
autowire: false #was added
autoconfigure: false #was added
arguments:
$managerRegistry: '@doctrine'
$myParam: 'value'
$logger: '@logger' #was added
tags:
- { name: 'api_platform.filter', id: 'my_filter' }The further research showed me that the problem is in the overridden constructor.
If I remove the constructor then autowiring works with the original service definition.
Looks like this issue was introduced by #2664
maks-rafalko
Metadata
Metadata
Assignees
Labels
No labels