You are here

public function CommentDefaultFormatter::__construct in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php \Drupal\comment\Plugin\Field\FieldFormatter\CommentDefaultFormatter::__construct()

Constructs a new CommentDefaultFormatter.

Parameters

string $plugin_id: The plugin_id for the formatter.

mixed $plugin_definition: The plugin implementation definition.

\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The definition of the field to which the formatter is associated.

array $settings: The formatter settings.

string $label: The formatter label display setting.

string $view_mode: The view mode.

array $third_party_settings: Third party settings.

\Drupal\Core\Session\AccountInterface $current_user: The current user.

\Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager: The entity type manager.

\Drupal\Core\Entity\EntityFormBuilderInterface $entity_form_builder: The entity form builder.

\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match object.

\Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository: The entity display repository.

Overrides FormatterBase::__construct

File

core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php, line 141

Class

CommentDefaultFormatter
Provides a default comment formatter.

Namespace

Drupal\comment\Plugin\Field\FieldFormatter

Code

public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, AccountInterface $current_user, EntityTypeManagerInterface $entity_type_manager, EntityFormBuilderInterface $entity_form_builder, RouteMatchInterface $route_match, EntityDisplayRepositoryInterface $entity_display_repository = NULL) {
  parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
  $this->viewBuilder = $entity_type_manager
    ->getViewBuilder('comment');
  $this->storage = $entity_type_manager
    ->getStorage('comment');
  $this->currentUser = $current_user;
  $this->entityFormBuilder = $entity_form_builder;
  $this->routeMatch = $route_match;
  if (!$entity_display_repository) {
    @trigger_error('Calling RssPluginBase::__construct() with the $entity_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
    $entity_display_repository = \Drupal::service('entity_display.repository');
  }
  $this->entityDisplayRepository = $entity_display_repository;
}