diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 60a491e..0612799 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -2928,7 +2928,15 @@ function drupal_classloader_register($name, $path) { * instead of the drupal_static() function. * * Example: - * @todo We need a new example. + * @code + * function system_get_module_info($property) { + * static $info; + * if (!isset($info)) { + * $info = new ModuleInfo('system_info', 'cache'); + * } + * return $info[$property]; + * } + * @endcode * * In a few cases, a function needs a resettable static variable, but the * function is called many times (100+) during a single page request, so diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 24e7890..2d5786d 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -185,6 +185,7 @@ public function getFormController($entity_type, $operation) { $class = $this->getControllerClass($entity_type, 'form', $operation); if (in_array('Drupal\Core\Entity\EntityControllerInterface', class_implements($class))) { $this->controllers['form'][$operation][$entity_type] = $class::createInstance($this->container, $entity_type, $this->getDefinition($entity_type)); + $this->controllers['form'][$operation][$entity_type]->setOperation($operation); } else { $this->controllers['form'][$operation][$entity_type] = new $class($operation); diff --git a/core/modules/action/lib/Drupal/action/ActionAddFormController.php b/core/modules/action/lib/Drupal/action/ActionAddFormController.php index 5b18fe4..d1b101c 100644 --- a/core/modules/action/lib/Drupal/action/ActionAddFormController.php +++ b/core/modules/action/lib/Drupal/action/ActionAddFormController.php @@ -8,11 +8,40 @@ namespace Drupal\action; use Drupal\Component\Utility\Crypt; +use Drupal\Core\Action\ActionManager; +use Drupal\Core\Entity\EntityControllerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a form controller for action add forms. */ -class ActionAddFormController extends ActionFormControllerBase { +class ActionAddFormController extends ActionFormControllerBase implements EntityControllerInterface { + + /** + * The action manager. + * + * @var \Drupal\Core\Action\ActionManager + */ + protected $actionManager; + + /** + * Constructs a new ActionAddFormController. + * + * @param \Drupal\Core\Action\ActionManager $action_manager + * The action plugin manager. + */ + public function __construct(ActionManager $action_manager) { + $this->actionManager = $action_manager; + } + + /** + * {@inheritdoc} + */ + public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { + return new static( + $container->get('plugin.manager.action') + ); + } /** * {@inheritdoc} @@ -21,10 +50,9 @@ class ActionAddFormController extends ActionFormControllerBase { * The hashed version of the action ID. */ public function buildForm(array $form, array &$form_state, $action_id = NULL) { - // @todo Inject the ActionManager after https://drupal.org/node/1909418. // In \Drupal\action\Form\ActionAdminManageForm::buildForm() the action // are hashed. Here we have to decrypt it to find the desired action ID. - foreach (\Drupal::service('plugin.manager.action')->getDefinitions() as $id => $definition) { + foreach ($this->actionManager->getDefinitions() as $id => $definition) { $key = Crypt::hashBase64($id); if ($key === $action_id) { $this->entity->setPlugin($id); diff --git a/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php b/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php index 7a7bc1f..29d1411 100644 --- a/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php +++ b/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php @@ -14,7 +14,7 @@ /** * Provides a base form controller for action forms. */ -class ActionFormControllerBase extends EntityFormController { +abstract class ActionFormControllerBase extends EntityFormController { /** * @var \Drupal\system\ActionInterface