You are here

public function NameFormatter::__construct in Name Field 8

Same name in this branch
  1. 8 src/NameFormatter.php \Drupal\name\NameFormatter::__construct()
  2. 8 src/Plugin/Field/FieldFormatter/NameFormatter.php \Drupal\name\Plugin\Field\FieldFormatter\NameFormatter::__construct()

Constructs a name formatter object.

Parameters

\Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager: The entity manager.

\Drupal\name\NameFormatParser $parser: The name format parser.

\Drupal\Core\Language\LanguageManagerInterface $language_manager: The language manager.

\Drupal\Core\StringTranslation\TranslationInterface $translation: The string translation.

\Drupal\Core\Config\ConfigFactoryInterface $config_factory: The factory for configuration objects.

File

src/NameFormatter.php, line 93

Class

NameFormatter
Primary name formatter for an array of name components.

Namespace

Drupal\name

Code

public function __construct(EntityTypeManagerInterface $entityTypeManager, NameFormatParser $parser, LanguageManagerInterface $language_manager, TranslationInterface $translation, ConfigFactoryInterface $config_factory) {
  $this->nameFormatStorage = $entityTypeManager
    ->getStorage('name_format');
  $this->listFormatStorage = $entityTypeManager
    ->getStorage('name_list_format');
  $this->parser = $parser;
  $this->languageManager = $language_manager;
  $this->stringTranslation = $translation;
  $this->configFactory = $config_factory;
  $config = $this->configFactory
    ->get('name.settings');
  $this->settings['sep1'] = $config
    ->get('sep1');
  $this->settings['sep2'] = $config
    ->get('sep2');
  $this->settings['sep3'] = $config
    ->get('sep3');
}