You are here

public function EntityTypeBuild::build in Replicate UI 8

Helper function for hook_entity_type_build().

Parameters

\Drupal\Core\Entity\EntityTypeInterface[] $entity_types: The entity type.

File

src/Hooks/EntityTypeBuild.php, line 50

Class

EntityTypeBuild
Implements hook_entity_type_build().

Namespace

Drupal\replicate_ui\Hooks

Code

public function build(array $entity_types) {
  $entity_types_with_replicate = (array) $this->configFactory
    ->get('replicate_ui.settings')
    ->get('entity_types');
  foreach ($entity_types as $entity_type_id => $entity_type) {
    if ($entity_type instanceof ContentEntityTypeInterface && $entity_type
      ->hasLinkTemplate('canonical') && in_array($entity_type_id, $entity_types_with_replicate, TRUE)) {
      $entity_type
        ->setFormClass('replicate', ReplicateConfirmForm::class);
      $entity_type
        ->setLinkTemplate('replicate', $entity_type
        ->getLinkTemplate('canonical') . '/replicate');
    }
  }
}