1 | <?php |
||
25 | trait EntityHelperTrait { |
||
26 | |||
27 | /** |
||
28 | * The entity manager service. |
||
29 | * |
||
30 | * @var \Drupal\Core\Entity\EntityManagerInterface |
||
31 | */ |
||
32 | protected $entityManager; |
||
33 | |||
34 | /** |
||
35 | * The module handler service. |
||
36 | * |
||
37 | * @var \Drupal\Core\Extension\ModuleHandlerInterface. |
||
38 | */ |
||
39 | protected $moduleHandler; |
||
40 | |||
41 | /** |
||
42 | * The Entity Embed Display plugin manager. |
||
43 | * |
||
44 | * @var \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManager. |
||
45 | */ |
||
46 | protected $displayPluginManager; |
||
47 | |||
48 | /** |
||
49 | * The renderer. |
||
50 | * |
||
51 | * @var \Drupal\Core\Render\RendererInterface. |
||
52 | */ |
||
53 | protected $renderer; |
||
54 | |||
55 | /** |
||
56 | * Loads an entity from the database. |
||
57 | * |
||
58 | * @param string $entity_type |
||
59 | * The entity type to load, e.g. node or user. |
||
60 | * @param mixed $id |
||
61 | * The id or UUID of the entity to load. |
||
62 | * |
||
63 | * @return \Drupal\Core\Entity\EntityInterface |
||
64 | * The entity object, or NULL if there is no entity with the given id or |
||
65 | * UUID. |
||
66 | */ |
||
67 | protected function loadEntity($entity_type, $id) { |
||
71 | |||
72 | /** |
||
73 | * Loads multiple entities from the database. |
||
74 | * |
||
75 | * @param string $entity_type |
||
76 | * The entity type to load, e.g. node or user. |
||
77 | * @param array $ids |
||
78 | * An array of entity IDs or UUIDs. |
||
79 | * |
||
80 | * @return array |
||
81 | * An array of entity objects indexed by their ids. |
||
82 | * |
||
83 | * @throws \Drupal\Core\Entity\EntityStorageException |
||
84 | * Throws an exception if the entity type does not supports UUIDs. |
||
85 | */ |
||
86 | protected function loadMultipleEntities($entity_type, array $ids) { |
||
105 | |||
106 | /** |
||
107 | * Determines if an entity can be rendered. |
||
108 | * |
||
109 | * @param \Drupal\Core\Entity\EntityInterface $entity |
||
110 | * The entity object. |
||
111 | * |
||
112 | * @return bool |
||
113 | * TRUE if the entity's type has a view builder controller, otherwise FALSE. |
||
114 | */ |
||
115 | protected function canRenderEntity(EntityInterface $entity) { |
||
119 | |||
120 | /** |
||
121 | * Determines if an entity type can be rendered. |
||
122 | * |
||
123 | * @param string $entity_type |
||
124 | * The entity type id. |
||
125 | * |
||
126 | * @return bool |
||
127 | * TRUE if the entitys type has a view builder controller, otherwise FALSE. |
||
128 | */ |
||
129 | protected function canRenderEntityType($entity_type) { |
||
132 | |||
133 | /** |
||
134 | * Returns the render array for an entity. |
||
135 | * |
||
136 | * @param \Drupal\Core\Entity\EntityInterface $entity |
||
137 | * The entity to be rendered. |
||
138 | * @param string $view_mode |
||
139 | * The view mode that should be used to display the entity. |
||
140 | * @param string $langcode |
||
141 | * (optional) For which language the entity should be rendered, defaults to |
||
142 | * the current content language. |
||
143 | * |
||
144 | * @return array |
||
145 | * A render array for the entity. |
||
146 | */ |
||
147 | protected function renderEntity(EntityInterface $entity, $view_mode, $langcode = NULL) { |
||
151 | |||
152 | /** |
||
153 | * Renders an embedded entity. |
||
154 | * |
||
155 | * @param \Drupal\Core\Entity\EntityInterface $entity |
||
156 | * The entity to be rendered. |
||
157 | * @param array $context |
||
158 | * (optional) Array of context values, corresponding to the attributes on |
||
159 | * the embed HTML tag. |
||
160 | * |
||
161 | * @return string |
||
162 | * The HTML of the entity rendered with the Entity Embed Display plugin. |
||
163 | */ |
||
164 | protected function renderEntityEmbed(EntityInterface $entity, array $context = array()) { |
||
221 | |||
222 | /** |
||
223 | * Renders an entity using an Entity Embed Display plugin. |
||
224 | * |
||
225 | * @param \Drupal\Core\Entity\EntityInterface $entity |
||
226 | * The entity to be rendered. |
||
227 | * @param string $plugin_id |
||
228 | * The Entity Embed Display plugin ID. |
||
229 | * @param array $plugin_configuration |
||
230 | * (optional) Array of plugin configuration values. |
||
231 | * @param array $context |
||
232 | * (optional) Array of additional context values, usually the embed HTML |
||
233 | * tag's attributes. |
||
234 | * |
||
235 | * @return array |
||
236 | * A render array for the Entity Embed Display plugin. |
||
237 | */ |
||
238 | protected function renderEntityEmbedDisplayPlugin(EntityInterface $entity, $plugin_id, array $plugin_configuration = array(), array $context = array()) { |
||
253 | |||
254 | /** |
||
255 | * Returns the entity manager. |
||
256 | * |
||
257 | * @return \Drupal\Core\Entity\EntityManagerInterface |
||
258 | * The entity manager. |
||
259 | */ |
||
260 | protected function entityManager() { |
||
266 | |||
267 | /** |
||
268 | * Sets the entity manager service. |
||
269 | * |
||
270 | * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager |
||
271 | * The entity manager service. |
||
272 | * |
||
273 | * @return self |
||
274 | */ |
||
275 | public function setEntityManager(EntityManagerInterface $entity_manager) { |
||
279 | |||
280 | /** |
||
281 | * Returns the module handler. |
||
282 | * |
||
283 | * @return \Drupal\Core\Extension\ModuleHandlerInterface |
||
284 | * The module handler. |
||
285 | */ |
||
286 | protected function moduleHandler() { |
||
292 | |||
293 | /** |
||
294 | * Sets the module handler service. |
||
295 | * |
||
296 | * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler |
||
297 | * The module handler service. |
||
298 | * |
||
299 | * @return self |
||
300 | */ |
||
301 | public function setModuleHandler(ModuleHandlerInterface $module_handler) { |
||
305 | |||
306 | /** |
||
307 | * Returns the Entity Embed Display plugin manager. |
||
308 | * |
||
309 | * @return \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManager |
||
310 | * The Entity Embed Display plugin manager. |
||
311 | */ |
||
312 | protected function displayPluginManager() { |
||
318 | |||
319 | /** |
||
320 | * Sets the Entity Embed Display plugin manager service. |
||
321 | * |
||
322 | * @param \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManager $display_plugin_manager |
||
323 | * The Entity Embed Display plugin manager service. |
||
324 | * |
||
325 | * @return self |
||
326 | */ |
||
327 | public function setDisplayPluginManager(EntityEmbedDisplayManager $display_plugin_manager) { |
||
331 | |||
332 | /** |
||
333 | * Returns the renderer. |
||
334 | * |
||
335 | * @return \Drupal\Core\Render\RendererInterface |
||
336 | * The renderer. |
||
337 | */ |
||
338 | protected function renderer() { |
||
344 | |||
345 | /** |
||
346 | * Sets the renderer. |
||
347 | * |
||
348 | * @param \Drupal\Core\Render\RendererInterface $renderer |
||
349 | * The renderer. |
||
350 | * |
||
351 | * @return self |
||
352 | */ |
||
353 | public function setRenderer(RendererInterface $renderer) { |
||
357 | } |
||
358 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..