Skip to content
Snippets Groups Projects

Use constructor property promotion

Files
8
@@ -18,46 +18,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/
class AutoEntityLabelForm extends ConfigFormBase {
/**
* The config factory.
*
* Subclasses should use the self::config() method, which may be overridden to
* address specific needs when loading config, rather than this property
* directly. See \Drupal\Core\Form\ConfigFormBase::config() for an example of
* this.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The route matcher.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
protected $routeMatch;
/**
* Module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
private $moduleHandler;
/**
* User.
*
* @var \Drupal\Core\Session\AccountInterface
*/
private $user;
/**
* The entity type machine name.
*
@@ -86,7 +46,7 @@ class AutoEntityLabelForm extends ConfigFormBase {
* Config Factory.
* @param \Drupal\Core\Config\TypedConfigManagerInterface|null $typed_config_manager
* The typed config manager.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* The entity type manager service.
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* Route Match.
@@ -98,13 +58,12 @@ class AutoEntityLabelForm extends ConfigFormBase {
public function __construct(
ConfigFactoryInterface $config_factory,
TypedConfigManagerInterface $typed_config_manager,
EntityTypeManagerInterface $entity_type_manager,
protected EntityTypeManagerInterface $entityTypeManager,
RouteMatchInterface $route_match,
ModuleHandlerInterface $moduleHandler,
AccountInterface $user,
private ModuleHandlerInterface $moduleHandler,
private AccountInterface $user,
) {
parent::__construct($config_factory, $typed_config_manager);
$this->entityTypeManager = $entity_type_manager;
$this->routeMatch = $route_match;
$route_options = $this->routeMatch->getRouteObject()->getOptions();
$array_keys = array_keys($route_options['parameters']);
@@ -112,8 +71,6 @@ class AutoEntityLabelForm extends ConfigFormBase {
$entity_type = $this->routeMatch->getParameter($this->entityType);
$this->entityBundle = $entity_type->id();
$this->entityTypeBundleOf = $entity_type->getEntityType()->getBundleOf();
$this->moduleHandler = $moduleHandler;
$this->user = $user;
}
/**
Loading