You are here

class RedhenConnectionLocalTask in RedHen CRM 8

Provides local task definitions for all entity bundles.

Hierarchy

Expanded class hierarchy of RedhenConnectionLocalTask

1 string reference to 'RedhenConnectionLocalTask'
redhen_connection.links.task.yml in modules/redhen_connection/redhen_connection.links.task.yml
modules/redhen_connection/redhen_connection.links.task.yml

File

modules/redhen_connection/src/Plugin/Derivative/RedhenConnectionLocalTask.php, line 17

Namespace

Drupal\redhen_connection\Plugin\Derivative
View source
class RedhenConnectionLocalTask extends DeriverBase implements ContainerDeriverInterface {
  use StringTranslationTrait;

  /**
   * The entity manager.
   *
   * @var \Drupal\Core\Entity\EntityManagerInterface
   */
  protected $service;

  /**
   * Creates an SalesforceMappingLocalTask object.
   *
   * @param ConnectionService $service
   *   The service manager.
   * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
   *   The translation manager.
   */
  public function __construct(ConnectionService $service, TranslationInterface $string_translation) {
    $this->service = $service;
    $this->stringTranslation = $string_translation;
  }

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

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $this->derivatives = [];
    foreach ($this->service
      ->getAllConnectionEntityTypes() as $entity_type_id => $entity_type) {
      if (!$entity_type
        ->hasLinkTemplate('redhen_connection')) {
        continue;
      }
      $this->derivatives["{$entity_type_id}.redhen_connection_tab"] = [
        'route_name' => "entity.{$entity_type_id}.redhen_connection",
        'title' => $this
          ->t('Connections'),
        'base_route' => "entity.{$entity_type_id}.canonical",
        'weight' => 20,
      ] + $base_plugin_definition;
    }
    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
RedhenConnectionLocalTask::$service protected property The entity manager.
RedhenConnectionLocalTask::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
RedhenConnectionLocalTask::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
RedhenConnectionLocalTask::__construct public function Creates an SalesforceMappingLocalTask object.
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.