entity_generic-8.x-3.x-dev/src/Plugin/Action/Derivative/UnarchiveActionDeriver.php

src/Plugin/Action/Derivative/UnarchiveActionDeriver.php
<?php

namespace Drupal\entity_generic\Plugin\Action\Derivative;

use Drupal\Core\Action\Plugin\Action\Derivative\EntityActionDeriverBase;
use Drupal\Core\Entity\EntityTypeInterface;

/**
 * Provides an action for each generic entity type.
 */
class UnarchiveActionDeriver 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('Unarchive @entity_type', ['@entity_type' => $entity_type->getSingularLabel()]);
        $definitions[$entity_type_id] = $definition;
      }
      $this->derivatives = $definitions;
    }

    return $this->derivatives;
  }

  /**
   * {@inheritdoc}
   */
  protected function isApplicable(EntityTypeInterface $entity_type) {
    return $entity_type->hasKey('archived');
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc