Skip to content

CustomFieldHooks

Custom Field hook implementations for the Helper module.


  • Full name: \Drupal\helper\Hook\CustomFieldHooks

Properties

moduleHandler

protected \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler

entityFieldManager

protected \Drupal\Core\Entity\EntityFieldManagerInterface $entityFieldManager

entityTypeManager

protected \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager

Methods

__construct

Constructs a new CustomFieldHooks object.

public __construct(\Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler, \Drupal\Core\Entity\EntityFieldManagerInterface $entityFieldManager, \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager): mixed

Parameters:

Parameter Type Description
$moduleHandler \Drupal\Core\Extension\ModuleHandlerInterface
$entityFieldManager \Drupal\Core\Entity\EntityFieldManagerInterface
$entityTypeManager \Drupal\Core\Entity\EntityTypeManagerInterface

alterEntityQuery

Implements hook_query_TAG_alter() for entity queries.

public alterEntityQuery(\Drupal\Core\Database\Query\AlterableInterface $query): void

Custom fields have no main property, so an entity query exists() or notExists() condition on one compiles to a non-existent "{field_name}_" column. Point those conditions at the entity_id column instead, which is always populated when the field has a value.

Parameters:

Parameter Type Description
$query \Drupal\Core\Database\Query\AlterableInterface

See Also:

  • https://www.drupal.org/project/custom_field/issues/3572612

alterCustomFieldConditions

Recursively rewrites custom field main property conditions.

protected alterCustomFieldConditions(array& $conditions, string[] $patterns): void

Parameters:

Parameter Type Description
$conditions array
The conditions array from a database condition, passed by reference.
$patterns string[]
Regular expressions matching the broken "{alias}.{field_name}_" column.