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