You are here

function replicate_ui_entity_operation in Replicate UI 8

Implements hook_entity_operation().

File

./replicate_ui.module, line 52
Provide a user interface for the Replicate API.

Code

function replicate_ui_entity_operation(EntityInterface $entity) {
  $operations = [];
  $supports_replicate = in_array($entity
    ->getEntityTypeId(), (array) \Drupal::config('replicate_ui.settings')
    ->get('entity_types'));
  if ($supports_replicate) {
    $url = $entity
      ->toUrl('replicate');
    if ($url
      ->access()) {
      $operations['replicate'] = [
        'title' => t('Replicate'),
        'weight' => 45,
        'url' => $url,
        'query' => [
          'destination' => NULL,
        ],
      ];
    }
  }
  return $operations;
}