Skip to content

Instantly share code, notes, and snippets.

@ozin7
Last active August 11, 2022 16:38
Show Gist options
  • Save ozin7/16227d2276be19d8713f76b031b02ab1 to your computer and use it in GitHub Desktop.
Save ozin7/16227d2276be19d8713f76b031b02ab1 to your computer and use it in GitHub Desktop.
Drupal 8: Override service methods(service decorator)
workspaces.entity.query.sql:
decorates: entity.query.sql
class: Drupal\workspaces\EntityQuery\QueryFactory
arguments:
- '@database'
- '@workspaces.manager'
public: false
decoration_priority: 50
tags:
- { name: backend_overridable }
<?php
/**
* Workspaces-specific entity query implementation.
*/
class QueryFactory extends BaseQueryFactory {
/**
* {@inheritdoc}
*/
public function getAggregate(EntityTypeInterface $entity_type, $conjunction) {
$class = QueryBase::getClass($this->namespaces, 'QueryAggregate');
return new $class($entity_type, $conjunction, $this->connection, $this->namespaces, $this->workspaceManager);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment