FieldTest.php

Same filename in this branch
  1. 10 core/modules/field/tests/src/Kernel/Plugin/migrate/source/d6/FieldTest.php
  2. 10 core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldTest.php
  3. 10 core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php
  4. 10 core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/FieldTest.php
Same filename in other branches
  1. 9 core/modules/field/tests/src/Kernel/Plugin/migrate/source/d6/FieldTest.php
  2. 9 core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldTest.php
  3. 9 core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php
  4. 9 core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/FieldTest.php
  5. 9 core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldTest.php
  6. 9 core/modules/quickedit/tests/src/FunctionalJavascript/FieldTest.php
  7. 8.9.x core/modules/field/tests/src/Kernel/Plugin/migrate/source/d6/FieldTest.php
  8. 8.9.x core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldTest.php
  9. 8.9.x core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php
  10. 8.9.x core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/FieldTest.php
  11. 8.9.x core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldTest.php
  12. 8.9.x core/modules/quickedit/tests/src/FunctionalJavascript/FieldTest.php
  13. 11.x core/modules/field/tests/src/Kernel/Plugin/migrate/source/d6/FieldTest.php
  14. 11.x core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldTest.php
  15. 11.x core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php
  16. 11.x core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/FieldTest.php
  17. 11.x core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldTest.php

Namespace

Drupal\views_test_data\Plugin\views\field

File

core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldTest.php

View source
<?php

namespace Drupal\views_test_data\Plugin\views\field;

use Drupal\views\Attribute\ViewsField;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;

/**
 * A test field handler.
 */
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;
    }
    
    /**
     * {@inheritdoc}
     */
    protected function addSelfTokens(&$tokens, $item) {
        $tokens['{{ test_token }}'] = $this->getTestValue();
    }
    
    /**
     * {@inheritdoc}
     */
    public function render(ResultRow $values) {
        return $this->sanitizeValue($this->getTestValue());
    }
    
    /**
     * A mock function which allows to call placeholder from public.
     *
     * @return string
     *   The result of the placeholder method.
     */
    public function getPlaceholder() {
        return $this->placeholder();
    }

}

Classes

Title Deprecated Summary
FieldTest A test field handler.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.