You are here

public static function ReferenceViewBuilder::createInstance in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_entity/src/ReferenceViewBuilder.php \Drupal\bibcite_entity\ReferenceViewBuilder::createInstance()

Instantiates a new instance of this entity handler.

This is a factory method that returns a new instance of this object. The factory should pass any needed dependencies into the constructor of this object, but not the container itself. Every call to this method must return a new instance of this object; that is, it may not implement a singleton.

Parameters

\Symfony\Component\DependencyInjection\ContainerInterface $container: The service container this object should use.

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.

Return value

static A new instance of the entity handler.

Overrides EntityViewBuilder::createInstance

File

modules/bibcite_entity/src/ReferenceViewBuilder.php, line 48

Class

ReferenceViewBuilder
Reference entity view builder.

Namespace

Drupal\bibcite_entity

Code

public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {

  /** @var \Symfony\Component\Serializer\Normalizer\NormalizerInterface $serializer */
  $serializer = $container
    ->get('serializer');

  /** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */
  $config_factory = $container
    ->get('config.factory');

  /** @var \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository */
  $entity_repository = $container
    ->get('entity.repository');

  /** @var \Drupal\Core\Language\LanguageManagerInterface $language_manager */
  $language_manager = $container
    ->get('language_manager');

  /** @var \Drupal\Core\Theme\Registry $theme_registry */
  $theme_registry = $container
    ->get('theme.registry');

  /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository */
  $entity_display_repository = $container
    ->get('entity_display.repository');
  return new static($entity_type, $serializer, $config_factory, $entity_repository, $language_manager, $theme_registry, $entity_display_repository);
}