You are here

class EntityFlagDeriver in farmOS 2.x

Provides an action deriver that finds entity types with a flag form.

Hierarchy

Expanded class hierarchy of EntityFlagDeriver

See also

\Drupal\farm_flag\Plugin\Action\EntityFlag

File

modules/core/flag/src/Plugin/Action/Derivative/EntityFlagDeriver.php, line 13

Namespace

Drupal\farm_flag\Plugin\Action\Derivative
View source
class EntityFlagDeriver extends EntityActionDeriverBase {

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    if (empty($this->derivatives)) {
      $definitions = [];
      foreach ($this
        ->getApplicableEntityTypes() as $entity_type_id => $entity_type) {
        $definition = $base_plugin_definition;
        $definition['type'] = $entity_type_id;
        $definition['label'] = $this
          ->t('Flag @entity_type', [
          '@entity_type' => $entity_type
            ->getSingularLabel(),
        ]);
        $definition['confirm_form_route_name'] = 'entity.' . $entity_type
          ->id() . '.flag_form';
        $definitions[$entity_type_id] = $definition;
      }
      $this->derivatives = $definitions;
    }
    return $this->derivatives;
  }

  /**
   * {@inheritdoc}
   */
  protected function isApplicable(EntityTypeInterface $entity_type) {
    return $entity_type
      ->hasLinkTemplate('flag-action-form');
  }

}

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
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.
EntityFlagDeriver::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides EntityActionDeriverBase::getDerivativeDefinitions
EntityFlagDeriver::isApplicable protected function Indicates whether the deriver can be used for the provided entity type. Overrides EntityActionDeriverBase::isApplicable
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.