FieldTest.php 1.33 KB
Newer Older
1
2
3
4
5
6
7
8
9
<?php

/**
 * @file
 * Definition of Drupal\views_test_data\Plugin\views\field\FieldTest.
 */

namespace Drupal\views_test_data\Plugin\views\field;

10
use Drupal\Component\Annotation\PluginID;
11
12
13
use Drupal\views\Plugin\views\field\FieldPluginBase;

/**
14
 * @PluginID("test_field")
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 */
class FieldTest extends FieldPluginBase {


  /**
   * A temporary stored test value for the test.
   *
   * @var string
   */
  protected $testValue;

  /**
   * Sets the testValue property.
   *
   * @param string $value
   *   The test value to set.
   */
  public function setTestValue($value) {
    $this->testValue = $value;
  }

  /**
   * Returns the testValue property.
   *
   * @return string
   */
  public function getTestValue() {
    return $this->testValue;
  }

  /**
46
   * Overrides Drupal\views\Plugin\views\field\FieldPluginBase::addSelfTokens().
47
   */
48
  protected function addSelfTokens(&$tokens, $item) {
49
50
51
52
53
54
55
56
57
58
    $tokens['[test-token]'] = $this->getTestValue();
  }

  /**
   * Overrides Drupal\views\Plugin\views\field\FieldPluginBase::render().
   */
  function render($values) {
    return $this->sanitizeValue($this->getTestValue());
  }

59
60
61
62
63
64
65
66
67
68
  /**
   * A mock function which allows to call placeholder from public.
   *
   * @return string
   *   The result of the placeholder method.
   */
  public function getPlaceholder() {
    return $this->placeholder();
  }

69
}