Mercurial > hg > isophonics-drupal-site
comparison core/modules/views/src/Entity/Render/RendererBase.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\views\Entity\Render; | |
4 | |
5 use Drupal\Core\Cache\Cache; | |
6 use Drupal\Core\Cache\CacheableDependencyInterface; | |
7 use Drupal\Core\Entity\EntityTypeInterface; | |
8 use Drupal\Core\Language\LanguageManagerInterface; | |
9 use Drupal\views\Plugin\views\query\QueryPluginBase; | |
10 use Drupal\views\ResultRow; | |
11 use Drupal\views\ViewExecutable; | |
12 | |
13 /** | |
14 * Defines a base class for entity renderers. | |
15 */ | |
16 abstract class RendererBase implements CacheableDependencyInterface { | |
17 | |
18 /** | |
19 * The view executable wrapping the view storage entity. | |
20 * | |
21 * @var \Drupal\views\ViewExecutable | |
22 */ | |
23 public $view; | |
24 | |
25 /** | |
26 * The language manager. | |
27 * | |
28 * @var \Drupal\Core\Language\LanguageManagerInterface | |
29 */ | |
30 protected $languageManager; | |
31 | |
32 /** | |
33 * The type of the entity being rendered. | |
34 * | |
35 * @var \Drupal\Core\Entity\EntityTypeInterface | |
36 */ | |
37 protected $entityType; | |
38 | |
39 /** | |
40 * Contains an array of render arrays, one for each rendered entity. | |
41 * | |
42 * @var array | |
43 */ | |
44 protected $build; | |
45 | |
46 /** | |
47 * Constructs a renderer object. | |
48 * | |
49 * @param \Drupal\views\ViewExecutable $view | |
50 * The entity row being rendered. | |
51 * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager | |
52 * The language manager. | |
53 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type | |
54 * The entity type. | |
55 */ | |
56 public function __construct(ViewExecutable $view, LanguageManagerInterface $language_manager, EntityTypeInterface $entity_type) { | |
57 $this->view = $view; | |
58 $this->languageManager = $language_manager; | |
59 $this->entityType = $entity_type; | |
60 } | |
61 | |
62 /** | |
63 * {@inheritdoc} | |
64 */ | |
65 public function getCacheMaxAge() { | |
66 return Cache::PERMANENT; | |
67 } | |
68 | |
69 /** | |
70 * {@inheritdoc} | |
71 */ | |
72 public function getCacheContexts() { | |
73 return []; | |
74 } | |
75 | |
76 /** | |
77 * {@inheritdoc} | |
78 */ | |
79 public function getCacheTags() { | |
80 return []; | |
81 } | |
82 | |
83 /** | |
84 * Alters the query if needed. | |
85 * | |
86 * @param \Drupal\views\Plugin\views\query\QueryPluginBase $query | |
87 * The query to alter. | |
88 * @param string $relationship | |
89 * (optional) The relationship, used by a field. | |
90 */ | |
91 abstract public function query(QueryPluginBase $query, $relationship = NULL); | |
92 | |
93 /** | |
94 * Runs before each entity is rendered. | |
95 * | |
96 * @param $result | |
97 * The full array of results from the query. | |
98 */ | |
99 public function preRender(array $result) { | |
100 } | |
101 | |
102 /** | |
103 * Renders entity data. | |
104 * | |
105 * @param \Drupal\views\ResultRow $row | |
106 * A single row of the query result. | |
107 * | |
108 * @return array | |
109 * A renderable array for the entity data contained in the result row. | |
110 */ | |
111 abstract public function render(ResultRow $row); | |
112 | |
113 } |