class BibciteEntityPreviewController in Bibliography & Citation 8
Same name and namespace in other branches
- 2.0.x modules/bibcite_entity/src/Controller/BibciteEntityPreviewController.php \Drupal\bibcite_entity\Controller\BibciteEntityPreviewController
Defines a controller to render a single bibcite entity in preview.
Hierarchy
- class \Drupal\Core\Entity\Controller\EntityViewController implements ContainerInjectionInterface, TrustedCallbackInterface uses DeprecatedServicePropertyTrait
- class \Drupal\bibcite_entity\Controller\BibciteEntityPreviewController
Expanded class hierarchy of BibciteEntityPreviewController
File
- modules/
bibcite_entity/ src/ Controller/ BibciteEntityPreviewController.php, line 15
Namespace
Drupal\bibcite_entity\ControllerView source
class BibciteEntityPreviewController extends EntityViewController {
/**
* Entity repository service.
*
* @var \Drupal\Core\Entity\EntityRepositoryInterface
*/
protected $repository;
/**
* {@inheritdoc}
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, RendererInterface $renderer, EntityRepositoryInterface $repository) {
parent::__construct($entity_type_manager, $renderer);
$this->repository = $repository;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager */
$entity_manager = $container
->get('entity_type.manager');
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = $container
->get('renderer');
/** @var \Drupal\Core\Entity\EntityRepositoryInterface $repository */
$repository = $container
->get('entity.repository');
return new static($entity_manager, $renderer, $repository);
}
/**
* {@inheritdoc}
*/
public function view(EntityInterface $bibcite_reference_preview, $view_mode_id = 'default', $langcode = NULL) {
$bibcite_reference_preview->preview_view_mode = $view_mode_id;
$build = parent::view($bibcite_reference_preview, $view_mode_id);
$build['#attached']['library'][] = 'bibcite_entity/reference.preview';
// Don't render cache previews.
unset($build['#cache']);
return $build;
}
/**
* The _title_callback for the page that renders a reference in preview.
*
* @param \Drupal\Core\Entity\EntityInterface $bibcite_reference_preview
* The current reference entity.
*
* @return string
* The page title.
*/
public function title(EntityInterface $bibcite_reference_preview) {
return $this->repository
->getTranslationFromContext($bibcite_reference_preview)
->label();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BibciteEntityPreviewController:: |
protected | property | Entity repository service. | |
BibciteEntityPreviewController:: |
public static | function |
Instantiates a new instance of this class. Overrides EntityViewController:: |
|
BibciteEntityPreviewController:: |
public | function | The _title_callback for the page that renders a reference in preview. | |
BibciteEntityPreviewController:: |
public | function |
Provides a page to render a single entity. Overrides EntityViewController:: |
|
BibciteEntityPreviewController:: |
public | function |
Creates an EntityViewController object. Overrides EntityViewController:: |
|
DeprecatedServicePropertyTrait:: |
public | function | Allows to access deprecated/removed properties. | |
EntityViewController:: |
protected | property | ||
EntityViewController:: |
protected | property | The entity type manager. | |
EntityViewController:: |
protected | property | The renderer service. | |
EntityViewController:: |
public | function | Pre-render callback to build the page title. | |
EntityViewController:: |
public static | function |
Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface:: |
|
EntityViewController:: |
public | function | Provides a page to render a single entity revision. | |
TrustedCallbackInterface:: |
constant | Untrusted callbacks throw exceptions. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger silenced E_USER_DEPRECATION errors. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger E_USER_WARNING errors. |