You are here

public function AutoEntityLabelForm::__construct in Automatic Entity Label 8

Same name and namespace in other branches
  1. 8.3 src/Form/AutoEntityLabelForm.php \Drupal\auto_entitylabel\Form\AutoEntityLabelForm::__construct()
  2. 8.2 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: The route.

Overrides ConfigFormBase::__construct

File

src/Form/AutoEntityLabelForm.php, line 51

Class

AutoEntityLabelForm
Class AutoEntityLabelForm.

Namespace

Drupal\auto_entitylabel\Form

Code

public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_manager, RouteMatchInterface $route_match) {
  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->entity_type_parameter = array_shift($array_keys);
  $entity_type = $this->route_match
    ->getParameter($this->entity_type_parameter);
  $this->entity_type_id = $entity_type
    ->id();
  $this->entity_type_provider = $entity_type
    ->getEntityType()
    ->getProvider();
}