Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / views / tests / modules / views_test_data / src / Plugin / views / row / RowTest.php
1 <?php
2
3 namespace Drupal\views_test_data\Plugin\views\row;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\views\Plugin\views\row\RowPluginBase;
7
8 /**
9  * Provides a general test row plugin.
10  *
11  * @ingroup views_row_plugins
12  *
13  * @ViewsRow(
14  *   id = "test_row",
15  *   title = @Translation("Test row plugin"),
16  *   help = @Translation("Provides a generic row test plugin."),
17  *   theme = "views_view_row_test",
18  *   display_types = {"normal", "test"}
19  * )
20  */
21 class RowTest extends RowPluginBase {
22
23   /**
24    * A string which will be output when the view is rendered.
25    *
26    * @var string
27    */
28   public $output;
29
30   /**
31    * {@inheritdoc}
32    */
33   protected function defineOptions() {
34     $options = parent::defineOptions();
35     $options['test_option'] = ['default' => ''];
36
37     return $options;
38   }
39
40   /**
41    * {@inheritdoc}
42    */
43   public function buildOptionsForm(&$form, FormStateInterface $form_state) {
44     parent::buildOptionsForm($form, $form_state);
45
46     $form['test_option'] = [
47       '#title' => $this->t('Test option'),
48       '#type' => 'textfield',
49       '#description' => $this->t('This is a textfield for test_option.'),
50       '#default_value' => $this->options['test_option'],
51     ];
52   }
53
54   /**
55    * Sets the output property.
56    *
57    * @param string $output
58    *   The string to output by this plugin.
59    */
60   public function setOutput($output) {
61     $this->output = $output;
62   }
63
64   /**
65    * Returns the output property.
66    *
67    * @return string
68    */
69   public function getOutput() {
70     return $this->output;
71   }
72
73   /**
74    * {@inheritdoc}
75    */
76   public function render($row) {
77     return $this->getOutput();
78   }
79
80   /**
81    * {@inheritdoc}
82    */
83   public function calculateDependencies() {
84     return [
85       'content' => ['RowTest'],
86     ];
87   }
88
89 }