Version 1
[yaffs-website] / web / core / modules / views / tests / modules / views_test_data / src / Plugin / views / field / FieldTest.php
1 <?php
2
3 namespace Drupal\views_test_data\Plugin\views\field;
4
5 use Drupal\views\Plugin\views\field\FieldPluginBase;
6 use Drupal\views\ResultRow;
7
8 /**
9  * @ViewsField("test_field")
10  */
11 class FieldTest extends FieldPluginBase {
12
13
14   /**
15    * A temporary stored test value for the test.
16    *
17    * @var string
18    */
19   protected $testValue;
20
21   /**
22    * Sets the testValue property.
23    *
24    * @param string $value
25    *   The test value to set.
26    */
27   public function setTestValue($value) {
28     $this->testValue = $value;
29   }
30
31   /**
32    * Returns the testValue property.
33    *
34    * @return string
35    */
36   public function getTestValue() {
37     return $this->testValue;
38   }
39
40   /**
41    * {@inheritdoc}
42    */
43   protected function addSelfTokens(&$tokens, $item) {
44     $tokens['{{ test_token }}'] = $this->getTestValue();
45   }
46
47   /**
48    * {@inheritdoc}
49    */
50   public function render(ResultRow $values) {
51     return $this->sanitizeValue($this->getTestValue());
52   }
53
54   /**
55    * A mock function which allows to call placeholder from public.
56    *
57    * @return string
58    *   The result of the placeholder method.
59    */
60   public function getPlaceholder() {
61     return $this->placeholder();
62   }
63
64 }