You are here

class PrintableLinksBlock in Printer and PDF versions for Drupal 8+ 8

Same name in this branch
  1. 8 src/Plugin/Derivative/PrintableLinksBlock.php \Drupal\printable\Plugin\Derivative\PrintableLinksBlock
  2. 8 src/Plugin/Block/PrintableLinksBlock.php \Drupal\printable\Plugin\Block\PrintableLinksBlock
Same name and namespace in other branches
  1. 2.x src/Plugin/Derivative/PrintableLinksBlock.php \Drupal\printable\Plugin\Derivative\PrintableLinksBlock

Local tasks plugin derivative to provide a tab for each printable format.

Hierarchy

Expanded class hierarchy of PrintableLinksBlock

1 file declares its use of PrintableLinksBlock
PrintableLinksBlockTest.php in tests/src/Unit/Plugin/Derivative/PrintableLinksBlockTest.php

File

src/Plugin/Derivative/PrintableLinksBlock.php, line 15

Namespace

Drupal\printable\Plugin\Derivative
View source
class PrintableLinksBlock extends DeriverBase implements ContainerDeriverInterface {
  use StringTranslationTrait;

  /**
   * The printable entity manager.
   *
   * @var \Drupal\printable\PrintableEntityManagerInterface
   */
  protected $printableEntityManager;

  /**
   * Construct a new printable format links block.
   *
   * @param \Drupal\printable\PrintableEntityManagerInterface $printable_entity_manager
   *   The printable entity manager.
   * @param \Drupal\Core\StringTranslation\TranslationInterface $translation_manager
   *   The translation manager.
   */
  public function __construct(PrintableEntityManagerInterface $printable_entity_manager, TranslationInterface $translation_manager) {
    $this->printableEntityManager = $printable_entity_manager;
    $this->stringTranslation = $translation_manager;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static($container
      ->get('printable.entity_manager'), $container
      ->get('string_translation'));
  }

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    foreach ($this->printableEntityManager
      ->getPrintableEntities() as $entity_type => $entity_definition) {
      $this->derivatives[$entity_type] = $base_plugin_definition;
      $this->derivatives[$entity_type]['admin_label'] = $this
        ->t('@name (@entity_name)', [
        '@name' => $this->derivatives[$entity_type]['admin_label'],
        '@entity_name' => $entity_definition
          ->getLabel(),
      ]);
    }
    return $this->derivatives;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
PrintableLinksBlock::$printableEntityManager protected property The printable entity manager.
PrintableLinksBlock::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
PrintableLinksBlock::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
PrintableLinksBlock::__construct public function Construct a new printable format links block.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.