You are here

public function AutoEntityLabelForm::__construct in Automatic Entity Label 8.2

Same name and namespace in other branches
  1. 8.3 src/Form/AutoEntityLabelForm.php \Drupal\auto_entitylabel\Form\AutoEntityLabelForm::__construct()
  2. 8 src/Form/AutoEntityLabelForm.php \Drupal\auto_entitylabel\Form\AutoEntityLabelForm::__construct()

AutoEntityLabelController constructor.

Parameters

\Drupal\Core\Config\ConfigFactoryInterface $config_factory: Config Factory.

\Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager: Entity Manager.

\Drupal\Core\Routing\RouteMatchInterface $route_match: Route Match.

\Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler: Module Handler.

\Drupal\Core\Session\AccountInterface $user: Account Interface.

Overrides ConfigFormBase::__construct

File

src/Form/AutoEntityLabelForm.php, line 95

Class

AutoEntityLabelForm
Class AutoEntityLabelForm.

Namespace

Drupal\auto_entitylabel\Form

Code

public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_manager, RouteMatchInterface $route_match, ModuleHandlerInterface $moduleHandler, AccountInterface $user) {
  parent::__construct($config_factory);
  $this->entityManager = $entity_manager;
  $this->route_match = $route_match;
  $route_options = $this->route_match
    ->getRouteObject()
    ->getOptions();
  $array_keys = array_keys($route_options['parameters']);
  $this->entityType = array_shift($array_keys);
  $entity_type = $this->route_match
    ->getParameter($this->entityType);
  $this->entityBundle = $entity_type
    ->id();
  $this->entityTypeBundleOf = $entity_type
    ->getEntityType()
    ->getBundleOf();
  $this->moduleHandler = $moduleHandler;
  $this->user = $user;
}