Verified Commit ef55a8fd authored by godotislate's avatar godotislate
Browse files

refactor: #3398534 Allow form service wiring via constructor parameter attributes

By: longwave
By: sidharth_soman
By: dcam
By: godotislate
parent c3a8de20
Loading
Loading
Loading
Loading
Loading
+0 −822

File changed.

Preview size limit exceeded, changes collapsed.

+0 −11
Changes for core/lib/Drupal/Core/Form/ConfigFormBase.php: 0 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -10,7 +10,6 @@
use Drupal\Component\Render\MarkupInterface;
use Drupal\Core\Render\Markup;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Base class for implementing system configuration forms.
@@ -48,16 +47,6 @@ public function __construct(
    $this->setConfigFactory($config_factory);
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('config.factory'),
      $container->get('config.typed')
    );
  }

  /**
   * Returns the typed config manager service.
   *
+2 −8
Changes for core/lib/Drupal/Core/Form/FormBase.php: 2 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\Core\Form;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\DependencyInjection\AutowireTrait;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Htmx\HtmxRequestInfoTrait;
@@ -10,7 +11,6 @@
use Drupal\Core\Routing\RedirectDestinationTrait;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\RequestStack;
use Drupal\Core\Messenger\MessengerTrait;
@@ -44,6 +44,7 @@
 */
abstract class FormBase implements FormInterface, ContainerInjectionInterface {

  use AutowireTrait;
  use DependencySerializationTrait;
  use HtmxRequestInfoTrait;
  use LoggerChannelTrait;
@@ -77,13 +78,6 @@ abstract class FormBase implements FormInterface, ContainerInjectionInterface {
   */
  protected $routeMatch;

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static();
  }

  /**
   * {@inheritdoc}
   */
+3 −38
Changes for core/modules/node/src/Form/NodePreviewForm.php: 3 added lines, 38 removed lines.
Original line number Diff line number Diff line
@@ -2,13 +2,11 @@

namespace Drupal\node\Form;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Contains a form for switching the view mode of a node during preview.
@@ -17,42 +15,9 @@
 */
class NodePreviewForm extends FormBase {

  /**
   * The entity display repository.
   *
   * @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface
   */
  protected $entityDisplayRepository;

  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('entity_display.repository'),
      $container->get('config.factory')
    );
  }

  /**
   * Constructs a new NodePreviewForm.
   *
   * @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository
   *   The entity display repository.
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The configuration factory.
   */
  public function __construct(EntityDisplayRepositoryInterface $entity_display_repository, ConfigFactoryInterface $config_factory) {
    $this->entityDisplayRepository = $entity_display_repository;
    $this->configFactory = $config_factory;
  }
  public function __construct(
    protected EntityDisplayRepositoryInterface $entityDisplayRepository,
  ) {}

  /**
   * {@inheritdoc}
+0 −15
Changes for core/modules/system/src/Form/CronForm.php: 0 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@
use Drupal\Core\Form\RedundantEditableConfigNamesTrait;
use Drupal\Core\State\StateInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Configure cron settings for this site.
@@ -40,20 +39,6 @@ protected function getEditableConfigNames() {
    return ['system.cron'];
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('config.factory'),
      $container->get('state'),
      $container->get('cron'),
      $container->get('date.formatter'),
      $container->get('module_handler'),
      $container->get('config.typed')
    );
  }

  /**
   * {@inheritdoc}
   */