class QueryFactory implements QueryFactoryInterface, EventSubscriberInterface (View source)

Provides a factory for creating entity query objects for the config backend.

Constants

CONFIG_LOOKUP_PREFIX

The prefix for the key value collection for fast lookups.

Properties

protected ConfigFactoryInterface $configFactory

The config factory used by the config entity query.

protected array $namespaces

The namespace of this class, the parent class etc.

Methods

__construct(ConfigFactoryInterface $config_factory, KeyValueFactoryInterface $key_value, ConfigManagerInterface $config_manager)

Constructs a QueryFactory object.

get(EntityTypeInterface $entity_type, string $conjunction)

Instantiates an entity query for a given entity type.

getAggregate(EntityTypeInterface $entity_type, string $conjunction)

Instantiates an aggregation query object for a given entity type.

getConfigKeyStore(EntityTypeInterface $entity_type)

Gets the key value store used to store fast lookups.

updateConfigKeyStore(ConfigEntityTypeInterface $entity_type, Config $config)

Updates or adds lookup data.

deleteConfigKeyStore(ConfigEntityTypeInterface $entity_type, Config $config)

Deletes lookup data.

array
getKeys(Config $config, string $key, string $get_method, ConfigEntityTypeInterface $entity_type)

Creates lookup keys for configuration data.

array|null
getValues(Config $config, string $key, string $get_method, array $parts, int $start = 0)

Finds all the values for a configuration key in a configuration object.

onConfigSave(ConfigCrudEvent $event)

Updates configuration entity in the key store.

onConfigDelete(ConfigCrudEvent $event)

Removes configuration entity from key store.

static 
getSubscribedEvents()

{@inheritdoc}

Details

__construct(ConfigFactoryInterface $config_factory, KeyValueFactoryInterface $key_value, ConfigManagerInterface $config_manager)

Constructs a QueryFactory object.

Parameters

ConfigFactoryInterface $config_factory

The config storage used by the config entity query.

KeyValueFactoryInterface $key_value

The key value factory.

ConfigManagerInterface $config_manager

The configuration manager.

QueryInterface get(EntityTypeInterface $entity_type, string $conjunction)

Instantiates an entity query for a given entity type.

Parameters

EntityTypeInterface $entity_type

The entity type definition.

string $conjunction

The operator to use to combine conditions: 'AND' or 'OR'.

Return Value

QueryInterface

An entity query for a specific configuration entity type.

QueryAggregateInterface getAggregate(EntityTypeInterface $entity_type, string $conjunction)

Instantiates an aggregation query object for a given entity type.

Parameters

EntityTypeInterface $entity_type

The entity type definition.

string $conjunction
  • AND: all of the conditions on the query need to match.
  • OR: at least one of the conditions on the query need to match.

Return Value

QueryAggregateInterface

The query object that can query the given entity type.

Exceptions

QueryException

protected KeyValueStoreInterface getConfigKeyStore(EntityTypeInterface $entity_type)

Gets the key value store used to store fast lookups.

Parameters

EntityTypeInterface $entity_type

The entity type.

Return Value

KeyValueStoreInterface

The key value store used to store fast lookups.

protected updateConfigKeyStore(ConfigEntityTypeInterface $entity_type, Config $config)

Updates or adds lookup data.

Parameters

ConfigEntityTypeInterface $entity_type

The entity type.

Config $config

The configuration object that is being saved.

protected deleteConfigKeyStore(ConfigEntityTypeInterface $entity_type, Config $config)

Deletes lookup data.

Parameters

ConfigEntityTypeInterface $entity_type

The entity type.

Config $config

The configuration object that is being deleted.

protected array getKeys(Config $config, string $key, string $get_method, ConfigEntityTypeInterface $entity_type)

Creates lookup keys for configuration data.

Parameters

Config $config

The configuration object.

string $key

The configuration key to look for.

string $get_method

Which method on the config object to call to get the value. Either 'get' or 'getOriginal'.

ConfigEntityTypeInterface $entity_type

The configuration entity type.

Return Value

array

An array of lookup keys concatenated to the configuration values.

Exceptions

InvalidLookupKeyException

protected array|null getValues(Config $config, string $key, string $get_method, array $parts, int $start = 0)

Finds all the values for a configuration key in a configuration object.

Parameters

Config $config

The configuration object.

string $key

The current key being checked.

string $get_method

Which method on the config object to call to get the value.

array $parts

All the parts of a configuration key we are checking.

int $start

Which position of $parts we are processing. Defaults to 0.

Return Value

array|null

The array of configuration values the match the provided key. NULL if the configuration object does not have a value that corresponds to the key.

onConfigSave(ConfigCrudEvent $event)

Updates configuration entity in the key store.

Parameters

ConfigCrudEvent $event

The configuration event.

onConfigDelete(ConfigCrudEvent $event)

Removes configuration entity from key store.

Parameters

ConfigCrudEvent $event

The configuration event.

static getSubscribedEvents()

{@inheritdoc}