You are here

class AddSimplenewsIssueActionLinks in Simplenews 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Derivative/AddSimplenewsIssueActionLinks.php \Drupal\simplenews\Plugin\Derivative\AddSimplenewsIssueActionLinks
  2. 3.x src/Plugin/Derivative/AddSimplenewsIssueActionLinks.php \Drupal\simplenews\Plugin\Derivative\AddSimplenewsIssueActionLinks

Provides dynamic link actions for simplenews content types.

Hierarchy

Expanded class hierarchy of AddSimplenewsIssueActionLinks

1 string reference to 'AddSimplenewsIssueActionLinks'
simplenews.links.action.yml in ./simplenews.links.action.yml
simplenews.links.action.yml

File

src/Plugin/Derivative/AddSimplenewsIssueActionLinks.php, line 12

Namespace

Drupal\simplenews\Plugin\Derivative
View source
class AddSimplenewsIssueActionLinks extends DeriverBase {

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $node_types = simplenews_get_content_types();
    $node_type = reset($node_types);
    if (count($node_types) == 1) {
      $label = NodeType::load($node_type)
        ->label();
      $this->derivatives[$node_type] = $base_plugin_definition;
      $this->derivatives[$node_type]['title'] = new TranslatableMarkup('Add @label', [
        '@label' => $label,
      ]);
      $this->derivatives[$node_type]['route_parameters'] = array(
        'node_type' => $node_type,
      );
    }
    elseif (count($node_types) > 1) {
      $base_plugin_definition['route_name'] = 'node.add_page';
      $base_plugin_definition['title'] = new TranslatableMarkup('Add content');
      $this->derivatives[] = $base_plugin_definition;
    }
    return parent::getDerivativeDefinitions($base_plugin_definition);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AddSimplenewsIssueActionLinks::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition