X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Faction%2Fsrc%2FActionAddForm.php;fp=web%2Fcore%2Fmodules%2Faction%2Fsrc%2FActionAddForm.php;h=59d56ecd90a032cb9145308460e3c1c0aa81af31;hp=25aaebc315d83ccb95b9853e42ea2cd7b69dcb1e;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/core/modules/action/src/ActionAddForm.php b/web/core/modules/action/src/ActionAddForm.php index 25aaebc31..59d56ecd9 100644 --- a/web/core/modules/action/src/ActionAddForm.php +++ b/web/core/modules/action/src/ActionAddForm.php @@ -2,67 +2,28 @@ namespace Drupal\action; -use Drupal\Component\Utility\Crypt; -use Drupal\Core\Action\ActionManager; -use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Form\FormStateInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a form for action add forms. + * + * @internal */ class ActionAddForm extends ActionFormBase { - /** - * The action manager. - * - * @var \Drupal\Core\Action\ActionManager - */ - protected $actionManager; - - /** - * Constructs a new ActionAddForm. - * - * @param \Drupal\Core\Entity\EntityStorageInterface $storage - * The action storage. - * @param \Drupal\Core\Action\ActionManager $action_manager - * The action plugin manager. - */ - public function __construct(EntityStorageInterface $storage, ActionManager $action_manager) { - parent::__construct($storage); - - $this->actionManager = $action_manager; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('entity.manager')->getStorage('action'), - $container->get('plugin.manager.action') - ); - } - /** * {@inheritdoc} * * @param string $action_id - * The hashed version of the action ID. + * The action ID. */ public function buildForm(array $form, FormStateInterface $form_state, $action_id = NULL) { - // In \Drupal\action\Form\ActionAdminManageForm::buildForm() the action - // are hashed. Here we have to decrypt it to find the desired action ID. - foreach ($this->actionManager->getDefinitions() as $id => $definition) { - $key = Crypt::hashBase64($id); - if ($key === $action_id) { - $this->entity->setPlugin($id); - // Derive the label and type from the action definition. - $this->entity->set('label', $definition['label']); - $this->entity->set('type', $definition['type']); - break; - } - } + $this->entity->setPlugin($action_id); + + // Derive the label and type from the action definition. + $definition = $this->entity->getPluginDefinition(); + $this->entity->set('label', $definition['label']); + $this->entity->set('type', $definition['type']); return parent::buildForm($form, $form_state); }