You are here

function simplenews_entity_operation in Simplenews 3.x

Same name and namespace in other branches
  1. 8.2 simplenews.module \simplenews_entity_operation()
  2. 8 simplenews.module \simplenews_entity_operation()

Implements hook_entity_operation().

File

./simplenews.module, line 154
Simplenews node handling, sent email, newsletter block and general hooks.

Code

function simplenews_entity_operation(EntityInterface $entity) {
  $operations = [];
  if ($entity
    ->getEntityTypeId() == 'node') {
    $url = Url::fromRoute('simplenews.node_tab', [
      'node' => $entity
        ->id(),
    ]);
    if ($url
      ->access()) {
      $operations['simplenews'] = [
        'title' => t('Newsletter'),
        'url' => $url,
        'weight' => 90,
      ];
    }
  }
  return $operations;
}