Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / views / src / Plugin / views / row / EntityReference.php
1 <?php
2
3 namespace Drupal\views\Plugin\views\row;
4
5 use Drupal\Core\Form\FormStateInterface;
6
7 /**
8  * EntityReference row plugin.
9  *
10  * @ingroup views_row_plugins
11  *
12  * @ViewsRow(
13  *   id = "entity_reference",
14  *   title = @Translation("Entity Reference inline fields"),
15  *   help = @Translation("Displays the fields with an optional template."),
16  *   theme = "views_view_fields",
17  *   register_theme = FALSE,
18  *   display_types = {"entity_reference"}
19  * )
20  */
21 class EntityReference extends Fields {
22
23   /**
24    * {@inheritdoc}
25    */
26   protected function defineOptions() {
27     $options = parent::defineOptions();
28     $options['separator'] = ['default' => '-'];
29
30     return $options;
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   public function buildOptionsForm(&$form, FormStateInterface $form_state) {
37     parent::buildOptionsForm($form, $form_state);
38
39     // Expand the description of the 'Inline field' checkboxes.
40     $form['inline']['#description'] .= '<br />' . $this->t("<strong>Note:</strong> In 'Entity Reference' displays, all fields will be displayed inline unless an explicit selection of inline fields is made here.");
41   }
42
43   /**
44    * {@inheritdoc}
45    */
46   public function preRender($row) {
47     // Force all fields to be inline by default.
48     if (empty($this->options['inline'])) {
49       $fields = $this->view->getHandlers('field', $this->displayHandler->display['id']);
50       $names = array_keys($fields);
51       $this->options['inline'] = array_combine($names, $names);
52     }
53
54     return parent::preRender($row);
55   }
56
57 }