Closed phansys closed 2 years ago
Should we add the 4.0 milestone ?
I think we could provide some of the required changes from 3.x.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
The FilterFactory is doing:
public function create(string $name, string $type, array $options = []): FilterInterface
{
if (!$this->container->has($type)) {
throw new \RuntimeException(sprintf('No attached service to type named `%s`', $type));
}
$filter = $this->container->get($type);
if (!$filter instanceof FilterInterface) {
throw new \RuntimeException(sprintf('The service `%s` must implement `FilterInterface`', $type));
}
$filter->initialize($name, $options);
return $filter;
}
How do you want to use the construct instead ?
And how would work a singleton ?
Friendly ping @phansys
Can you detail the two choices you gave ? Currently the initialize method is used here: https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/Filter/FilterFactory.php#L33-L48
To me constructor cannot be used since we're loading the filter as a service in the container (because it can depends on some others services). And I dunno what you had in mind by initialize as a singleton
.
Closing due to lack of interest
Feature Request
Since there is a specific state required for the filter objects (the classes implementing
Sonata\AdminBundle\Filter\FilterInterface
) to work, we should provide a way to ensure their state is ready to use, at least in our own implementation. I think we have 2 choices:__construct()
method atSonata\AdminBundle\Filter\Filter
and set the required state there;Sonata\AdminBundle\Filter\Filter::initialize()
method into a singleton and set the required state there.This feature request is created to avoid situations like the exposed in this comment.
TO DO: