Security update to Drupal 8.4.6
[yaffs-website] / web / core / modules / quickedit / quickedit.api.php
1 <?php
2
3 /**
4  * @file
5  * Hooks provided by the Edit module.
6  */
7
8 /**
9  * @addtogroup hooks
10  * @{
11  */
12
13 /**
14  * Allow modules to alter in-place editor plugin metadata.
15  *
16  * This hook is called after the in-place editor plugins have been discovered,
17  * but before they are cached. Hence any alterations will be cached.
18  *
19  * @param array &$editors
20  *   An array of metadata on existing in-place editors, as collected by the
21  *   annotation discovery mechanism.
22  *
23  * @see \Drupal\quickedit\Annotation\InPlaceEditor
24  * @see \Drupal\quickedit\Plugin\EditorManager
25  */
26 function hook_quickedit_editor_alter(&$editors) {
27   // Cleanly override editor.module's in-place editor plugin.
28   $editors['editor']['class'] = 'Drupal\advanced_editor\Plugin\quickedit\editor\AdvancedEditor';
29 }
30
31 /**
32  * Returns a renderable array for the value of a single field in an entity.
33  *
34  * To integrate with in-place field editing when a non-standard render pipeline
35  * is used (FieldItemListInterface::view() is not sufficient to render back the
36  * field following in-place editing in the exact way it was displayed
37  * originally), implement this hook.
38  *
39  * Edit module integrates with HTML elements with data-edit-field-id attributes.
40  * For example:
41  *   data-edit-field-id="node/1/<field-name>/und/<module-name>-<custom-id>"
42  * After the editing is complete, this hook is invoked on the module with
43  * the custom render pipeline identifier (last part of data-edit-field-id) to
44  * re-render the field. Use the same logic used when rendering the field for
45  * the original display.
46  *
47  * The implementation should take care of invoking the prepare_view steps. It
48  * should also respect field access permissions.
49  *
50  * @param \Drupal\Core\Entity\EntityInterface $entity
51  *   The entity containing the field to display.
52  * @param string $field_name
53  *   The name of the field to display.
54  * @param string $view_mode_id
55  *   View mode ID for the custom render pipeline this field view was destined
56  *   for. This is not a regular view mode ID for the Entity/Field API render
57  *   pipeline and is provided by the renderer module instead. An example could
58  *   be Views' render pipeline. In the example of Views, the view mode ID would
59  *   probably contain the View's ID, display and the row index. Views would
60  *   know the internal structure of this ID. The only structure imposed on this
61  *   ID is that it contains dash separated values and the first value is the
62  *   module name. Only that module's hook implementation will be invoked. Eg.
63  *   'views-...-...'.
64  * @param string $langcode
65  *   (Optional) The language code the field values are to be shown in.
66  *
67  * @return
68  *   A renderable array for the field value.
69  *
70  * @see \Drupal\Core\Field\FieldItemListInterface::view()
71  */
72 function hook_quickedit_render_field(Drupal\Core\Entity\EntityInterface $entity, $field_name, $view_mode_id, $langcode) {
73   return [
74     '#prefix' => '<div class="example-markup">',
75     'field' => $entity->getTranslation($langcode)->get($field_name)->view($view_mode_id),
76     '#suffix' => '</div>',
77   ];
78 }
79
80 /**
81  * @} End of "addtogroup hooks".
82  */