diff --git a/core/lib/Drupal/Core/Form/FormBase.php b/core/lib/Drupal/Core/Form/FormBase.php index d4e5722..2d1c9af 100644 --- a/core/lib/Drupal/Core/Form/FormBase.php +++ b/core/lib/Drupal/Core/Form/FormBase.php @@ -16,8 +16,8 @@ * Provides a base class for forms. * * This class exists as a mid-point between dependency injection through - * ContainerInjectionInterface, and a less-structured use of traits which use - * the \Drupal accessor for service discovery. + * ContainerInjectionInterface, and a less-structured use of traits which + * default to using the \Drupal accessor for service discovery. * * To properly inject services, override create() and use the setters provided * by the traits to inject the needed services. @@ -26,13 +26,19 @@ * public static function create($container) { * $form = new static(); * // In this example we only need string translation so we use the - * // setStringTranslatin() method provided by StringTranslationTrait. + * // setStringTranslation() method provided by StringTranslationTrait. * $form->setStringTranslation($container->get('string_translation')); * return $form; * } * @endcode * + * Alternately, you could not use FormBase, implement FormInterface, use only + * the traits you actually need, and inject the services in a container + * injection pattern you define. + * * @ingroup form_api + * + * @see \Drupal\Core\DependencyInjection\ContainerInjectionInterface */ abstract class FormBase implements FormInterface, ContainerInjectionInterface {