ViewsQueryAlter
class ViewsQueryAlter implements ContainerInjectionInterface (View source)
| internal |
Defines a class for altering views queries.
Properties
| protected EntityTypeManagerInterface | $entityTypeManager | The entity type manager service. |
|
| protected EntityFieldManagerInterface | $entityFieldManager | The entity field manager. |
|
| protected WorkspaceManagerInterface | $workspaceManager | The workspace manager service. |
|
| protected ViewsData | $viewsData | The views data. |
|
| protected ViewsHandlerManager | $viewsJoinPluginManager | A plugin manager which handles instances of views join plugins. |
|
| protected LanguageManagerInterface | $languageManager | The language manager. |
Methods
Constructs a new ViewsQueryAlter instance.
Instantiates a new instance of this class.
Implements a hook bridge for hook_views_query_alter().
Alters the entity type tables for a Views query.
Adds the 'workspace_association' table to a views query.
Adds the revision table of an entity type to a query object.
Fetches a join for a revision table using the workspace_association table.
Moves a 'workspace_association' table to appear before the given alias.
Details
__construct(EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, WorkspaceManagerInterface $workspace_manager, ViewsData $views_data, ViewsHandlerManager $views_join_plugin_manager, LanguageManagerInterface $language_manager)
Constructs a new ViewsQueryAlter instance.
static
create(ContainerInterface $container)
Instantiates a new instance of this class.
This is a factory method that returns a new instance of this class. The factory should pass any needed dependencies into the constructor of this class, but not the container itself. Every call to this method must return a new instance of this class; that is, it may not implement a singleton.
alterQuery(ViewExecutable $view, QueryPluginBase $query)
Implements a hook bridge for hook_views_query_alter().
protected
alterQueryForEntityType(Sql $query, EntityTypeInterface $entity_type)
Alters the entity type tables for a Views query.
This should only be called after determining that this entity type is involved in the query, and that a non-default workspace is in use.
protected string
ensureWorkspaceAssociationTable(string $entity_type_id, Sql $query, string $relationship)
Adds the 'workspace_association' table to a views query.
protected string
ensureRevisionTable(EntityTypeInterface $entity_type, Sql $query, string $relationship)
Adds the revision table of an entity type to a query object.
protected JoinPluginInterface
getRevisionTableJoin(string $relationship, string $table, string $field, string $workspace_association_table, EntityTypeInterface $entity_type)
Fetches a join for a revision table using the workspace_association table.
protected
moveEntityTable(Sql $query, string $workspace_association_table, string $alias)
Moves a 'workspace_association' table to appear before the given alias.
Because Workspace chains possibly pre-existing tables onto the 'workspace_association' table, we have to ensure that the 'workspace_association' table appears in the query before the alias it's chained on or the SQL is invalid.