If your module extends the DatabaseStorageController
class and wants to reuse the default SQL Query backend in Drupal\Core\Entity\Query\Sql\Query
then you need to extend the QueryFactory
class in a new namespace with the same name but you do not need to write any code; it will just work. Say,
namespace Drupal\foo\Entity\Mystorage;
use Drupal\Core\Entity\Query\Sql\QueryFactory as BaseQueryFactory
class QueryFactory extends BaseQueryFactory {
}
will return instances of class Drupal\foo\Entity\Mystorage\Query
if it exists, if not then class Drupal\Core\Entity\Query\Sql\Query
. Once the empty QueryFactory
is added, the system automatically will pick up the Query
, QueryAggregate
, Condition
and Table
classes in the current or any of the parent namespaces as adequate.