diff --git a/core/includes/form.inc b/core/includes/form.inc index 8bd89fb..8ead9e4 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -7,7 +7,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Form\FormInterface; -use Drupal\Core\Form\BaseFormInterface; +use Drupal\Core\Form\BaseFormIdInterface; use Drupal\Core\Database\Database; use Drupal\Core\Template\Attribute; use Drupal\Core\Datetime\DrupalDateTime; @@ -120,7 +120,7 @@ function _drupal_form_id($form_arg, &$form_state) { // the callback object and determine the form ID. if (is_object($form_arg) && $form_arg instanceof FormInterface) { $form_state['build_info']['callback_object'] = $form_arg; - if ($form_arg instanceof BaseFormInterface) { + if ($form_arg instanceof BaseFormIdInterface) { $form_state['build_info']['base_form_id'] = $form_arg->getBaseFormID(); } return $form_arg->getFormID(); diff --git a/core/lib/Drupal/Core/Entity/EntityFormControllerInterface.php b/core/lib/Drupal/Core/Entity/EntityFormControllerInterface.php index 28b2562..289df86 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormControllerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityFormControllerInterface.php @@ -7,12 +7,12 @@ namespace Drupal\Core\Entity; -use Drupal\Core\Form\BaseFormInterface; +use Drupal\Core\Form\BaseFormIdInterface; /** * Defines a common interface for entity form controller classes. */ -interface EntityFormControllerInterface extends BaseFormInterface { +interface EntityFormControllerInterface extends BaseFormIdInterface { /** * Returns the code identifying the active form language. diff --git a/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php b/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php index 9177a23..8237ba1 100644 --- a/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php +++ b/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php @@ -18,7 +18,8 @@ class HtmlEntityFormController extends HtmlFormController { /** * {@inheritdoc} * - * Due to reflection, the argument must be named $_entity_form. + * Due to reflection, the argument must be named $_entity_form. The parent + * method has $request and $_form, but the parameter must match the route. */ public function content(Request $request, $_entity_form) { return parent::content($request, $_entity_form); @@ -27,7 +28,7 @@ public function content(Request $request, $_entity_form) { /** * Overrides \Drupal\Core\HtmlFormController::getFormObject(). * - * Instead of a class name or service ID, $arg will be a string representing + * Instead of a class name or service ID, $form_arg will be a string representing * the entity and operation being performed. * Consider the following route: * @code @@ -35,7 +36,7 @@ public function content(Request $request, $_entity_form) { * defaults: * _entity_form: 'node.edit' * @endcode - * This would mean the edit form controller for the node entity should be use. + * This means that the edit form controller for the node entity will used. * If the entity type has a default form controller, only the name of the * entity {param} needs to be passed: * @code @@ -44,17 +45,17 @@ public function content(Request $request, $_entity_form) { * _entity_form: 'node' * @endcode */ - protected function getFormObject(Request $request, $arg) { + protected function getFormObject(Request $request, $form_arg) { $manager = $this->container->get('plugin.manager.entity'); // If no operation is provided, use 'default'. - $arg .= '.default'; - list ($entity, $operation) = explode('.', $arg); + $form_arg .= '.default'; + list ($entity, $operation) = explode('.', $form_arg); if ($request->attributes->has($entity)) { $entity = $request->attributes->get($entity); } - elseif (is_string($entity)) { + else { $entity = $manager->getStorageController($entity)->create(array()); } diff --git a/core/lib/Drupal/Core/Form/BaseFormInterface.php b/core/lib/Drupal/Core/Form/BaseFormIdInterface.php similarity index 58% rename from core/lib/Drupal/Core/Form/BaseFormInterface.php rename to core/lib/Drupal/Core/Form/BaseFormIdInterface.php index fa624cd..f948aac 100644 --- a/core/lib/Drupal/Core/Form/BaseFormInterface.php +++ b/core/lib/Drupal/Core/Form/BaseFormIdInterface.php @@ -2,23 +2,24 @@ /** * @file - * Contains \Drupal\Core\Form\BaseFormInterface. + * Contains \Drupal\Core\Form\BaseFormIdInterface. */ namespace Drupal\Core\Form; /** * Provides an interface for a Form that has a base form ID. + * + * This will become the $form_state['build_info']['base_form_id'] used to + * generate the name of hook_form_BASE_FORM_ID_alter(). */ -interface BaseFormInterface extends FormInterface { +interface BaseFormIdInterface extends FormInterface { /** * Returns a string identifying the base form. * * @return string|false * The string identifying the base form or FALSE if this is not a base form. - * - * The unique string identifying the form. */ public function getBaseFormID(); diff --git a/core/lib/Drupal/Core/HtmlFormController.php b/core/lib/Drupal/Core/HtmlFormController.php index a589396..e19d8ea 100644 --- a/core/lib/Drupal/Core/HtmlFormController.php +++ b/core/lib/Drupal/Core/HtmlFormController.php @@ -71,24 +71,24 @@ public function content(Request $request, $_form) { * * @param \Symfony\Component\HttpFoundation\Request $request * The request using this form. - * @param string $arg + * @param string $form_arg * Either a class name or a service ID. * * @return \Drupal\Core\Form\FormInterface * The form object to use. */ - protected function getFormObject(Request $request, $arg) { + protected function getFormObject(Request $request, $form_arg) { // If this is a class, instantiate it. - if (class_exists($arg)) { - if (in_array('Drupal\Core\ControllerInterface', class_implements($arg))) { - return $arg::create($this->container); + if (class_exists($form_arg)) { + if (in_array('Drupal\Core\ControllerInterface', class_implements($form_arg))) { + return $form_arg::create($this->container); } - return new $arg(); + return new $form_arg(); } // Otherwise, it is a service. - return $this->container->get($arg); + return $this->container->get($form_arg); } }