diff --git a/core/core.services.yml b/core/core.services.yml index 8f2965a..2acd8d1 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -194,6 +194,8 @@ services: entity.manager: class: Drupal\Core\Entity\EntityManager arguments: ['@container.namespaces', '@service_container', '@module_handler', '@cache.cache', '@language_manager', '@string_translation'] + entity.content.form_helper: + class: Drupal\Core\Entity\ContentEntityFormHelper plugin.manager.field.field_type: class: Drupal\Core\Field\FieldTypePluginManager arguments: ['@container.namespaces', '@cache.field', '@language_manager', '@module_handler'] diff --git a/core/lib/Drupal/Core/Entity/ContentEntityFormController.php b/core/lib/Drupal/Core/Entity/ContentEntityFormController.php index e5d58d3..d0383d6 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityFormController.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityFormController.php @@ -25,13 +25,23 @@ class ContentEntityFormController extends EntityFormController implements Conten protected $entityManager; /** + * The ContentEntity form helper. + * + * @var \Drupal\Core\Entity\ContentEntityFormHelper + */ + protected $entityFormHelper; + + /** * Constructs a ContentEntityFormController object. * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. + * @param \Drupal\Core\Entity\ContentEntityFormHelper $entity_form_helper + * The ContentEntity form helper. */ - public function __construct(EntityManagerInterface $entity_manager) { + public function __construct(EntityManagerInterface $entity_manager, ContentEntityFormHelper $entity_form_helper) { $this->entityManager = $entity_manager; + $this->EntityFormHelper = $entity_form_helper; } /** @@ -39,7 +49,8 @@ public function __construct(EntityManagerInterface $entity_manager) { */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager') + $container->get('entity.manager'), + $container->get('entity.content.form_helper') ); } @@ -47,7 +58,7 @@ public static function create(ContainerInterface $container) { * {@inheritdoc} */ public function form(array $form, array &$form_state) { - $this::attachWidgets($this->entity, $form_state['form_display'], $form, $form_state); + $this->EntityFormHelper->attachWidgets($this->entity, $form_state['form_display'], $form, $form_state); // Add a process callback so we can assign weights and hide extra fields. $form['#process'][] = array($this, 'processForm'); @@ -88,7 +99,7 @@ public function validate(array $form, array &$form_state) { $this->updateFormLangcode($form_state); $entity = $this->buildEntity($form, $form_state); - $this::validateWidgets($entity, $form_state['form_display'], $form, $form_state); + $this->EntityFormHelper->validateWidgetsValues($entity, $form_state['form_display'], $form, $form_state); // @todo Remove this. // Execute legacy global validation handlers. @@ -138,7 +149,7 @@ public function buildEntity(array $form, array &$form_state) { $entity = clone $this->entity; // First, extract values from widgets. - $extracted = $this::extractWidgetsValue($entity, $form_state['form_display'], $form, $form_state); + $extracted = $this->EntityFormHelper->extractWidgetsValue($entity, $form_state['form_display'], $form, $form_state); // Then extract the values of fields that are not rendered through widgets, // by simply copying from top-level form values. This leaves the fields @@ -174,69 +185,4 @@ public function setFormDisplay(EntityFormDisplayInterface $form_display, array & return $this; } - - - - // @todo Decide where those "generic widget attacher" methods should go. - // - Stay as static methods here ? - // Means everything has to be injected (module handler for hooks...) - // - Switch to regular, non static methods ? - // then $entity & $display params should be removed in favor of getFormDisplay() / getEntity(), - // it means other forms like EditFieldForm need to call setEntity() / setFormDisplay() - // before calling those. - // - Move to a different, yet to be introduced, ContentEntityFormHandler class - // that is *not* a form itself... - - public static function attachWidgets(EntityInterface $entity, EntityFormDisplayInterface $display, array &$form, array &$form_state) { - // Set #parents to 'top-level' by default. - $form += array('#parents' => array()); - - // Let each widget generate the form elements. - foreach ($entity as $name => $items) { - if ($widget = $display->getRenderer($name)) { - $items->filterEmptyValues(); - $form += $widget->form($items, $form, $form_state); - - // Assign the correct weight. This duplicates the reordering done in - // processForm(), but is needed for other forms calling this method - // directly. - $options = $display->getComponent($name); - $form[$name]['#weight'] = $options['weight']; - } - } - - // @todo hook_field_attach_form() ? - // We still need a hook to allow alteration of "forms with widgets", because - // the regular "entity form" alter hook won't run non "non enity forms"... - // Although, there's already hook_field_widget_form_alter() to alter each widget ? - } - - public static function extractWidgetsValue(EntityInterface $entity, EntityFormDisplayInterface $display, array &$form, array &$form_state) { - $extracted = array(); - - // Extract widget values. - foreach ($entity as $name => $items) { - if ($widget = $display->getRenderer($name)) { - $widget->extractFormValues($items, $form, $form_state); - $extracted[$name] = $name; - } - } - // @todo hook_field_attach_extract_form_values() ? - See above. - - return $extracted; - } - - public static function validateWidgets(EntityInterface $entity, EntityFormDisplayInterface $display, array &$form, array &$form_state) { - foreach ($entity as $field_name => $items) { - // Only validate the fields that actually appear in the form, and let the - // widget assign the violations to the right form elements. - if ($widget = $display->getRenderer($field_name)) { - $violations = $items->validate(); - if (count($violations)) { - $widget->flagErrors($items, $violations, $form, $form_state); - } - } - } - } - } diff --git a/core/lib/Drupal/Core/Entity/ContentEntityFormHelper.php b/core/lib/Drupal/Core/Entity/ContentEntityFormHelper.php new file mode 100644 index 0000000..de0b5e1 --- /dev/null +++ b/core/lib/Drupal/Core/Entity/ContentEntityFormHelper.php @@ -0,0 +1,110 @@ + array()); + + // Let each widget generate the form elements. + foreach ($entity as $name => $items) { + if ($widget = $display->getRenderer($name)) { + $items->filterEmptyValues(); + $form += $widget->form($items, $form, $form_state); + + // Assign the correct weight. This duplicates the reordering done in + // processForm(), but is needed for other forms calling this method + // directly. + $options = $display->getComponent($name); + $form[$name]['#weight'] = $options['weight']; + } + } + + // @todo hook_field_attach_form() ? + // We still need a hook to allow alteration of "forms with widgets", because + // the regular "entity form" alter hook won't run non "non enity forms"... + // Although, there's already hook_field_widget_form_alter() to alter each widget ? + } + + /** + * Extracts field values from the submitted widget values into the entity. + * + * @param EntityInterface $entity + * The entity. + * @param EntityFormDisplayInterface $display + * The form display containing the widget settings. + * @param array $form + * The form. + * @param array $form_state + * The form state. + * + * @return array + * An array whose keys and values are the keys of the top-level entries in + * $form_state['values'] that have been processed. The remaining entries, if + * any, do not correspond to widgets and should be extracted manually by + * the caller if needed. + */ + public function extractWidgetsValue(EntityInterface $entity, EntityFormDisplayInterface $display, array &$form, array &$form_state) { + $extracted = array(); + + foreach ($entity as $name => $items) { + if ($widget = $display->getRenderer($name)) { + $widget->extractFormValues($items, $form, $form_state); + $extracted[$name] = $name; + } + } + // @todo hook_field_attach_extract_form_values() ? - See above. + + return $extracted; + } + + /** + * Validates submitted widget values and sets the corresponding form errors. + * + * @param EntityInterface $entity + * The entity. + * @param EntityFormDisplayInterface $display + * The form display containing the widget settings. + * @param array $form + * The form. + * @param array $form_state + * The form state. + */ + public function validateWidgetsValues(EntityInterface $entity, EntityFormDisplayInterface $display, array &$form, array &$form_state) { + foreach ($entity as $field_name => $items) { + // Only validate the fields that actually appear in the form, and let the + // widget assign the violations to the right form elements. + if ($widget = $display->getRenderer($field_name)) { + $violations = $items->validate(); + if (count($violations)) { + $widget->flagErrors($items, $violations, $form, $form_state); + } + } + } + } + +} diff --git a/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php b/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php index 5364d93..06d2c66 100644 --- a/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php +++ b/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php @@ -8,6 +8,7 @@ namespace Drupal\book\Form; use Drupal\Core\Entity\ContentEntityFormController; +use Drupal\Core\Entity\ContentEntityFormHelper; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\book\BookManager; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -36,11 +37,13 @@ class BookOutlineForm extends ContentEntityFormController { * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. + * @param \Drupal\Core\Entity\ContentEntityFormHelper $entity_form_helper + * The ContentEntity form helper. * @param \Drupal\book\BookManager $book_manager * The BookManager service. */ - public function __construct(EntityManagerInterface $entity_manager, BookManager $book_manager) { - parent::__construct($entity_manager); + public function __construct(EntityManagerInterface $entity_manager, ContentEntityFormHelper $entity_form_helper, BookManager $book_manager) { + parent::__construct($entity_manager, $entity_form_helper); $this->bookManager = $book_manager; } @@ -50,6 +53,7 @@ public function __construct(EntityManagerInterface $entity_manager, BookManager public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), + $container->get('entity.content.form_helper'), $container->get('book.manager') ); } diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index 8a5d52f..8abfa2d 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -12,6 +12,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Entity\ContentEntityFormController; +use Drupal\Core\Entity\ContentEntityFormHelper; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Language\Language; use Drupal\Core\Session\AccountInterface; @@ -36,6 +37,7 @@ class CommentFormController extends ContentEntityFormController { public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), + $container->get('entity.content.form_helper'), $container->get('field.info'), $container->get('current_user') ); @@ -46,13 +48,15 @@ public static function create(ContainerInterface $container) { * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager service. + * @param \Drupal\Core\Entity\ContentEntityFormHelper $entity_form_helper + * The ContentEntity form helper. * @param \Drupal\field\FieldInfo $field_info * The field info service. * @param \Drupal\Core\Session\AccountInterface $current_user * The current user. */ - public function __construct(EntityManagerInterface $entity_manager, FieldInfo $field_info, AccountInterface $current_user) { - parent::__construct($entity_manager); + public function __construct(EntityManagerInterface $entity_manager, ContentEntityFormHelper $entity_form_helper, FieldInfo $field_info, AccountInterface $current_user) { + parent::__construct($entity_manager, $entity_form_helper); $this->fieldInfo = $field_info; $this->currentUser = $current_user; } diff --git a/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php b/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php index 60b2036..9e1d126 100644 --- a/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php +++ b/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php @@ -10,6 +10,7 @@ use Drupal\comment\CommentManagerInterface; use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\ContentEntityConfirmFormBase; +use Drupal\Core\Entity\ContentEntityFormHelper; use Drupal\Core\Entity\EntityManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -30,11 +31,13 @@ class DeleteForm extends ContentEntityConfirmFormBase { * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. + * @param \Drupal\Core\Entity\ContentEntityFormHelper $entity_form_helper + * The ContentEntity form helper. * @param \Drupal\comment\CommentManagerInterface $comment_manager * The comment manager service. */ - public function __construct(EntityManagerInterface $entity_manager, CommentManagerInterface $comment_manager) { - parent::__construct($entity_manager); + public function __construct(EntityManagerInterface $entity_manager, ContentEntityFormHelper $entity_form_helper, CommentManagerInterface $comment_manager) { + parent::__construct($entity_manager, $entity_form_helper); $this->commentManager = $comment_manager; } @@ -44,6 +47,7 @@ public function __construct(EntityManagerInterface $entity_manager, CommentManag public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), + $container->get('entity.content.form_helper'), $container->get('comment.manager') ); } diff --git a/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php b/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php index e492324..7ae8698 100644 --- a/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php +++ b/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php @@ -7,6 +7,7 @@ namespace Drupal\edit\Form; +use Drupal\Core\Entity\ContentEntityFormHelper; use Drupal\Core\Form\FormBase; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Entity\EntityInterface; @@ -42,6 +43,13 @@ class EditFieldForm extends FormBase { protected $nodeTypeStorage; /** + * The ContentEntity form helper. + * + * @var \Drupal\Core\Entity\ContentEntityFormHelper + */ + protected $entityFormHelper; + + /** * Constructs a new EditFieldForm. * * @param \Drupal\user\TempStoreFactory $temp_store_factory @@ -51,10 +59,11 @@ class EditFieldForm extends FormBase { * @param \Drupal\Core\Entity\EntityStorageControllerInterface $node_type_storage * The node type storage. */ - public function __construct(TempStoreFactory $temp_store_factory, ModuleHandlerInterface $module_handler, EntityStorageControllerInterface $node_type_storage) { + public function __construct(TempStoreFactory $temp_store_factory, ModuleHandlerInterface $module_handler, EntityStorageControllerInterface $node_type_storage, ContentEntityFormHelper $entity_form_helper) { + $this->tempStoreFactory = $temp_store_factory; $this->moduleHandler = $module_handler; $this->nodeTypeStorage = $node_type_storage; - $this->tempStoreFactory = $temp_store_factory; + $this->entityFormHelper = $entity_form_helper; } /** @@ -64,7 +73,8 @@ public static function create(ContainerInterface $container) { return new static( $container->get('user.tempstore'), $container->get('module_handler'), - $container->get('entity.manager')->getStorageController('node_type') + $container->get('entity.manager')->getStorageController('node_type'), + $container->get('entity.content.form_helper') ); } @@ -86,9 +96,7 @@ public function buildForm(array $form, array &$form_state, EntityInterface $enti } // Add the field form. - // @todo should the class be a property in $this ? - $class = \Drupal::entityManager()->getControllerClass($entity->entityType(), 'form', 'default'); - $class::attachWidgets($entity, $form_state['form_display'], $form, $form_state); + $this->entityFormHelper->attachWidgets($entity, $form_state['form_display'], $form, $form_state); // Add a dummy changed timestamp field to attach form errors to. if ($entity instanceof EntityChangedInterface) { @@ -146,8 +154,7 @@ protected function init(array &$form_state, EntityInterface $entity, $field_name public function validateForm(array &$form, array &$form_state) { $entity = $this->buildEntity($form, $form_state); - $class = \Drupal::entityManager()->getControllerClass($entity->entityType(), 'form', 'default'); - $class::validateWidgets($entity, $form_state['form_display'], $form, $form_state); + $this->entityFormHelper->validateWidgetsValues($entity, $form_state['form_display'], $form, $form_state); // Do validation on the changed field as well and assign the error to the // dummy form element we added for this. We don't know the name of this @@ -182,8 +189,7 @@ protected function buildEntity(array $form, array &$form_state) { $entity = clone $form_state['entity']; $field_name = $form_state['field_name']; - $class = \Drupal::entityManager()->getControllerClass($entity->entityType(), 'form', 'default'); - $class::extractWidgetsValue($entity, $form_state['form_display'], $form, $form_state); + $this->entityFormHelper->extractWidgetsValue($entity, $form_state['form_display'], $form, $form_state); // @todo Refine automated log messages and abstract them to all entity // types: http://drupal.org/node/1678002. diff --git a/core/modules/field/field.deprecated.inc b/core/modules/field/field.deprecated.inc index d520f9a..1358149 100644 --- a/core/modules/field/field.deprecated.inc +++ b/core/modules/field/field.deprecated.inc @@ -539,8 +539,7 @@ function field_read_instances($conditions = array(), $include_additional = array * @see field_form_set_state() */ function field_attach_form(EntityInterface $entity, &$form, &$form_state, $langcode = NULL, array $options = array()) { - $class = \Drupal::entityManager()->getControllerClass($entity->entityType(), 'form', 'default'); - $class::attachWidgets($entity, $form_state['form_display'], $form, $form_state); + \Drupal::service('entity.content.form_helper')->attachWidgets($entity, $form_state['form_display'], $form, $form_state); } /** @@ -575,8 +574,7 @@ function field_attach_form(EntityInterface $entity, &$form, &$form_state, $langc * @deprecated as of Drupal 8.0. Use the entity system instead. */ function field_attach_form_validate(ContentEntityInterface $entity, $form, &$form_state, array $options = array()) { - $class = \Drupal::entityManager()->getControllerClass($entity->entityType(), 'form', 'default'); - $class::validateWidgets($entity, $form_state['form_display'], $form, $form_state); + \Drupal::service('entity.content.form_helper')->validateWidgetsValues($entity, $form_state['form_display'], $form, $form_state); } /** @@ -600,8 +598,7 @@ function field_attach_form_validate(ContentEntityInterface $entity, $form, &$for * @deprecated as of Drupal 8.0. Use the entity system instead. */ function field_attach_extract_form_values(EntityInterface $entity, $form, &$form_state, array $options = array()) { - $class = \Drupal::entityManager()->getControllerClass($entity->entityType(), 'form', 'default'); - $class::extractWidgetsValue($entity, $form_state['form_display'], $form, $form_state); + \Drupal::service('entity.content.form_helper')->extractWidgetsValue($entity, $form_state['form_display'], $form, $form_state); } /** diff --git a/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php b/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php index 644b069..cafb32a 100644 --- a/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php +++ b/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\ContentEntityConfirmFormBase; +use Drupal\Core\Entity\ContentEntityFormHelper; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Routing\UrlGeneratorInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -30,11 +31,13 @@ class NodeDeleteForm extends ContentEntityConfirmFormBase { * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. + * @param \Drupal\Core\Entity\ContentEntityFormHelper $entity_form_helper + * The ContentEntity form helper. * @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator * The URL generator. */ - public function __construct(EntityManagerInterface $entity_manager, UrlGeneratorInterface $url_generator) { - parent::__construct($entity_manager); + public function __construct(EntityManagerInterface $entity_manager, ContentEntityFormHelper $entity_form_helper, UrlGeneratorInterface $url_generator) { + parent::__construct($entity_manager, $entity_form_helper); $this->urlGenerator = $url_generator; } @@ -44,6 +47,7 @@ public function __construct(EntityManagerInterface $entity_manager, UrlGenerator public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), + $container->get('entity.content.form_helper'), $container->get('url_generator') ); } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutFormController.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutFormController.php index 7179886..a37d052 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutFormController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutFormController.php @@ -8,6 +8,7 @@ namespace Drupal\shortcut; use Drupal\Core\Entity\ContentEntityFormController; +use Drupal\Core\Entity\ContentEntityFormHelper; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Form\FormBuilderInterface; @@ -47,6 +48,8 @@ class ShortcutFormController extends ContentEntityFormController { * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. + * @param \Drupal\Core\Entity\ContentEntityFormHelper $entity_form_helper + * The ContentEntity form helper. * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager * The path alias manager. * @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator @@ -54,8 +57,8 @@ class ShortcutFormController extends ContentEntityFormController { * @param \Drupal\Core\Form\FormBuilderInterface $form_builder * The form builder. */ - public function __construct(EntityManagerInterface $entity_manager, AliasManagerInterface $alias_manager, UrlGeneratorInterface $url_generator, FormBuilderInterface $form_builder) { - $this->entityManager = $entity_manager; + public function __construct(EntityManagerInterface $entity_manager, ContentEntityFormHelper $entity_form_helper, AliasManagerInterface $alias_manager, UrlGeneratorInterface $url_generator, FormBuilderInterface $form_builder) { + parent::__construct($entity_manager, $entity_form_helper); $this->aliasManager = $alias_manager; $this->urlGenerator = $url_generator; $this->formBuilder = $form_builder; @@ -67,6 +70,7 @@ public function __construct(EntityManagerInterface $entity_manager, AliasManager public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), + $container->get('entity.content.form_helper'), $container->get('path.alias_manager'), $container->get('url_generator'), $container->get('form_builder') diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php index 925d83c..7b1096b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php @@ -10,6 +10,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Entity\ContentEntityFormController; +use Drupal\Core\Entity\ContentEntityFormHelper; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Language\Language; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -31,11 +32,13 @@ class TermFormController extends ContentEntityFormController { * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. + * @param \Drupal\Core\Entity\ContentEntityFormHelper $entity_form_helper + * The ContentEntity form helper. * @param \Drupal\Core\Config\ConfigFactory $config_factory * The config factory. */ - public function __construct(EntityManagerInterface $entity_manager, ConfigFactory $config_factory) { - parent::__construct($entity_manager); + public function __construct(EntityManagerInterface $entity_manager, ContentEntityFormHelper $entity_form_helper, ConfigFactory $config_factory) { + parent::__construct($entity_manager, $entity_form_helper); $this->configFactory = $config_factory; } @@ -45,6 +48,7 @@ public function __construct(EntityManagerInterface $entity_manager, ConfigFactor public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), + $container->get('entity.content.form_helper'), $container->get('config.factory') ); } diff --git a/core/modules/user/lib/Drupal/user/AccountFormController.php b/core/modules/user/lib/Drupal/user/AccountFormController.php index 4983b0f..ad04293 100644 --- a/core/modules/user/lib/Drupal/user/AccountFormController.php +++ b/core/modules/user/lib/Drupal/user/AccountFormController.php @@ -8,6 +8,7 @@ namespace Drupal\user; use Drupal\Core\Entity\ContentEntityFormController; +use Drupal\Core\Entity\ContentEntityFormHelper; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManager; @@ -30,11 +31,13 @@ * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. + * @param \Drupal\Core\Entity\ContentEntityFormHelper $entity_form_helper + * The ContentEntity form helper. * @param \Drupal\Core\Language\LanguageManager $language_manager * The language manager. */ - public function __construct(EntityManagerInterface $entity_manager, LanguageManager $language_manager) { - parent::__construct($entity_manager); + public function __construct(EntityManagerInterface $entity_manager, ContentEntityFormHelper $entity_form_helper, LanguageManager $language_manager) { + parent::__construct($entity_manager, $entity_form_helper); $this->languageManager = $language_manager; } @@ -44,6 +47,7 @@ public function __construct(EntityManagerInterface $entity_manager, LanguageMana public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), + $container->get('entity.content.form_helper'), $container->get('language_manager') ); } diff --git a/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php b/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php index e1a3c6a..f1cd388 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Entity\ContentEntityConfirmFormBase; +use Drupal\Core\Entity\ContentEntityFormHelper; use Drupal\Core\Entity\EntityManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -43,11 +44,13 @@ class UserCancelForm extends ContentEntityConfirmFormBase { * * @param \Drupal\Core\Config\ConfigFactory $config_factory * The config factory. + * @param \Drupal\Core\Entity\ContentEntityFormHelper $entity_form_helper + * The ContentEntity form helper. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. */ - public function __construct(EntityManagerInterface $entity_manager, ConfigFactory $config_factory) { - parent::__construct($entity_manager); + public function __construct(EntityManagerInterface $entity_manager, ContentEntityFormHelper $entity_form_helper, ConfigFactory $config_factory) { + parent::__construct($entity_manager, $entity_form_helper); $this->configFactory = $config_factory; } @@ -57,6 +60,7 @@ public function __construct(EntityManagerInterface $entity_manager, ConfigFactor public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), + $container->get('entity.content.form_helper'), $container->get('config.factory') ); }