You are here

public static function OverrideHelper::entityHandler in Lightning Core 8.3

Same name and namespace in other branches
  1. 8.5 src/OverrideHelper.php \Drupal\lightning_core\OverrideHelper::entityHandler()
  2. 8 src/OverrideHelper.php \Drupal\lightning_core\OverrideHelper::entityHandler()
  3. 8.2 src/OverrideHelper.php \Drupal\lightning_core\OverrideHelper::entityHandler()
  4. 8.4 src/OverrideHelper.php \Drupal\lightning_core\OverrideHelper::entityHandler()

Overrides the class used for an entity handler.

The replacement class is only used if its immediate parent is the handler class specified by the entity type definition.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.

string $handler_type: The handler type.

string $replacement_class: The class to use.

File

src/OverrideHelper.php, line 78

Class

OverrideHelper
Helps tweak and override implementations of various things.

Namespace

Drupal\lightning_core

Code

public static function entityHandler(EntityTypeInterface $entity_type, $handler_type, $replacement_class) {
  if (get_parent_class($replacement_class) == $entity_type
    ->getHandlerClass($handler_type)) {
    $entity_type
      ->setHandlerClass($handler_type, $replacement_class);
  }
}