You are here

public function EntityTypeInfo::entityOperation in Webform Analysis 8

Same name in this branch
  1. 8 src/EntityTypeInfo.php \Drupal\webform_analysis\EntityTypeInfo::entityOperation()
  2. 8 modules/webform_node_analysis/src/EntityTypeInfo.php \Drupal\webform_node_analysis\EntityTypeInfo::entityOperation()

Adds devel operations on entity that supports it.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity on which to define an operation.

Return value

array An array of operation definitions.

See also

hook_entity_operation()

File

src/EntityTypeInfo.php, line 73

Class

EntityTypeInfo
Manipulates entity type information.

Namespace

Drupal\webform_analysis

Code

public function entityOperation(EntityInterface $entity) {
  $operations = [];
  if ($this->currentUser
    ->hasPermission('view any webform submission')) {
    if ($entity
      ->hasLinkTemplate('results_analysis')) {
      $operations['analysis'] = [
        'title' => $this
          ->t('Analysis'),
        'weight' => 100,
        'url' => $entity
          ->toUrl('results_analysis'),
      ];
    }
  }
  return $operations;
}