You are here

class AddUpdateFieldLocalAction in Scheduled Updates 8

Hierarchy

Expanded class hierarchy of AddUpdateFieldLocalAction

1 string reference to 'AddUpdateFieldLocalAction'
scheduled_updates.links.action.yml in ./scheduled_updates.links.action.yml
scheduled_updates.links.action.yml

File

src/Plugin/Derivative/AddUpdateFieldLocalAction.php, line 19
Contains \Drupal\scheduled_updates\Plugin\Derivative\AddUpdateFieldLocalAction.

Namespace

Drupal\scheduled_updates\Plugin\Derivative
View source
class AddUpdateFieldLocalAction extends DeriverBase implements ContainerDeriverInterface {
  use StringTranslationTrait;

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

  /**
   * Constructs a FieldUiLocalAction object.
   *
   * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
   *   The route provider to load routes by name.
   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
   *   The entity manager.
   */
  public function __construct(RouteProviderInterface $route_provider, EntityManagerInterface $entity_manager) {
    $this->routeProvider = $route_provider;
    $this->entityManager = $entity_manager;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static($container
      ->get('router.route_provider'), $container
      ->get('entity.manager'));
  }

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $this->derivatives = array();
    foreach ($this->entityManager
      ->getDefinitions() as $entity_type_id => $entity_type) {
      if ($entity_type_id == 'scheduled_update') {
        continue;
      }
      if ($entity_type
        ->get('field_ui_base_route')) {
        $this->derivatives["scheduled_update_field_add_{$entity_type_id}"] = array(
          'route_name' => "entity.scheduled_update_type.add_form.field.{$entity_type_id}",
          'title' => $this
            ->t('Add Update field'),
          'appears_on' => array(
            "entity.{$entity_type_id}.field_ui_fields",
          ),
          'query' => [
            'entity_type_id' => $entity_type_id,
          ],
          'route_parameters' => [
            'entity_type_id' => $entity_type_id,
          ],
          'defaults' => [
            'mode' => 'embedded',
          ],
        );
      }
    }
    foreach ($this->derivatives as &$entry) {
      $entry += $base_plugin_definition;
    }
    return $this->derivatives;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AddUpdateFieldLocalAction::$entityManager protected property The entity manager
AddUpdateFieldLocalAction::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
AddUpdateFieldLocalAction::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
AddUpdateFieldLocalAction::__construct public function Constructs a FieldUiLocalAction object.
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
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.