You are here

class ContentEntityLingotekActionDeriver in Lingotek Translation 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Action/Derivative/ContentEntityLingotekActionDeriver.php \Drupal\lingotek\Plugin\Action\Derivative\ContentEntityLingotekActionDeriver
  2. 4.0.x src/Plugin/Action/Derivative/ContentEntityLingotekActionDeriver.php \Drupal\lingotek\Plugin\Action\Derivative\ContentEntityLingotekActionDeriver
  3. 3.1.x src/Plugin/Action/Derivative/ContentEntityLingotekActionDeriver.php \Drupal\lingotek\Plugin\Action\Derivative\ContentEntityLingotekActionDeriver
  4. 3.2.x src/Plugin/Action/Derivative/ContentEntityLingotekActionDeriver.php \Drupal\lingotek\Plugin\Action\Derivative\ContentEntityLingotekActionDeriver
  5. 3.3.x src/Plugin/Action/Derivative/ContentEntityLingotekActionDeriver.php \Drupal\lingotek\Plugin\Action\Derivative\ContentEntityLingotekActionDeriver
  6. 3.4.x src/Plugin/Action/Derivative/ContentEntityLingotekActionDeriver.php \Drupal\lingotek\Plugin\Action\Derivative\ContentEntityLingotekActionDeriver
  7. 3.5.x src/Plugin/Action/Derivative/ContentEntityLingotekActionDeriver.php \Drupal\lingotek\Plugin\Action\Derivative\ContentEntityLingotekActionDeriver
  8. 3.6.x src/Plugin/Action/Derivative/ContentEntityLingotekActionDeriver.php \Drupal\lingotek\Plugin\Action\Derivative\ContentEntityLingotekActionDeriver
  9. 3.7.x src/Plugin/Action/Derivative/ContentEntityLingotekActionDeriver.php \Drupal\lingotek\Plugin\Action\Derivative\ContentEntityLingotekActionDeriver
  10. 3.8.x src/Plugin/Action/Derivative/ContentEntityLingotekActionDeriver.php \Drupal\lingotek\Plugin\Action\Derivative\ContentEntityLingotekActionDeriver

Hierarchy

Expanded class hierarchy of ContentEntityLingotekActionDeriver

File

src/Plugin/Action/Derivative/ContentEntityLingotekActionDeriver.php, line 11

Namespace

Drupal\lingotek\Plugin\Action\Derivative
View source
class ContentEntityLingotekActionDeriver extends EntityActionDeriverBase {

  /**
   * {@inheritdoc}
   */
  protected function isApplicable(EntityTypeInterface $entity_type) {
    return TRUE;

    /** @var \Drupal\lingotek\LingotekConfigurationServiceInterface $drupalConfiguration */
    $drupalConfiguration = \Drupal::service('lingotek.configuration');
    return $drupalConfiguration
      ->isEnabled($entity_type
      ->id());
  }

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $definitions = parent::getDerivativeDefinitions($base_plugin_definition);
    if (!empty($definitions)) {
      $entity_types = $this->entityTypeManager
        ->getDefinitions();
      foreach ($this->derivatives as $entity_type_id => &$definition) {
        $definition['label'] = new FormattableMarkup($base_plugin_definition['action_label'], [
          '@entity_label' => $entity_types[$entity_type_id]
            ->getSingularLabel(),
        ]);
        if (in_array($definition['class'], [
          DeleteAllTranslationsAction::class,
          DeleteTranslationLingotekAction::class,
        ])) {
          $definition['confirm_form_route_name'] = 'entity.' . $entity_type_id . '.delete_multiple_form';
        }
      }
    }
    return parent::getDerivativeDefinitions($base_plugin_definition);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContentEntityLingotekActionDeriver::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides EntityActionDeriverBase::getDerivativeDefinitions
ContentEntityLingotekActionDeriver::isApplicable protected function Indicates whether the deriver can be used for the provided entity type. Overrides EntityActionDeriverBase::isApplicable
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
EntityActionDeriverBase::$entityTypeManager protected property The entity type manager.
EntityActionDeriverBase::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
EntityActionDeriverBase::getApplicableEntityTypes protected function Gets a list of applicable entity types.
EntityActionDeriverBase::__construct public function Constructs a new EntityActionDeriverBase object.
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
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.