- Issue created by @joachim
- 🇬🇧United Kingdom joachim
Also, the workspaces QueryFactory extends from the original QueryFactory. That's a problem as well for other code that wants to do the same.
The decorated QueryFactory should be injected, and called with $this->decorated->method() rather than parent::method().
- 🇬🇧United Kingdom joachim
This system for extending queries is documented in \Drupal\Core\Entity\Query\Sql\pgsql\QueryFactory:
* To add a new query implementation extending the default SQL one, add * a service definition like pgsql.entity.query.sql and a factory class like * this. The system will automatically find the relevant Query, QueryAggregate, * Condition, ConditionAggregate, Tables classes in this namespace, in the * namespace of the parent class and so on. So after creating an empty query * factory class like this, it is possible to just drop in a class extending * the base class in this namespace and it will be used automatically but it * is optional: if a class is not extended the relevant default is used. * * @see \Drupal\Core\Entity\Query\QueryBase::getNamespaces() * @see \Drupal\Core\Entity\Query\QueryBase::getClass()
Reading this, it sounds to me like the intention was that custom code could extend query classes for site-specific needs. It's designed as something that can be customised one time. It's not extensible by multiple modules, and workspace module having bagsied this functionality means nobody else can do it.
- Status changed to Postponed
9 months ago 11:12am 8 March 2024 - 🇷🇴Romania amateescu
The way Workspaces entity query alter works might be improved after 📌 Add an alter hook to EntityQuery RTBC and #2502363: Add getters to EntityQuery → , so postponing on those issues.
FWIW, the Trash module has to do exactly what's described in the issue summary, and provide alternative EQ classes for both "vanilla" ones as well as the Workspace overrides :(