SingleInternalPropertyTestFieldItem.php
Same filename in other branches
Namespace
Drupal\entity_test\Plugin\Field\FieldTypeFile
-
core/
modules/ system/ tests/ modules/ entity_test/ src/ Plugin/ Field/ FieldType/ SingleInternalPropertyTestFieldItem.php
View source
<?php
declare (strict_types=1);
namespace Drupal\entity_test\Plugin\Field\FieldType;
use Drupal\Core\Field\Attribute\FieldType;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Field\Plugin\Field\FieldType\StringItem;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\TypedData\DataDefinition;
use Drupal\entity_test\TypedData\ComputedString;
/**
* Defines the 'Single Internal Property' entity test field type.
*
* This is based off of the InternalPropertyTestFieldItem test field item type,
* but only adds a single computed property. This tests that fields with a main
* property name and one internal value are flattened.
*
* @see \Drupal\entity_test\Plugin\Field\FieldType\InternalPropertyTestFieldItem
*/
class SingleInternalPropertyTestFieldItem extends StringItem {
/**
* {@inheritdoc}
*/
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
$properties = parent::propertyDefinitions($field_definition);
// Add a computed property that is internal.
$properties['internal_value'] = DataDefinition::create('string')->setLabel(new TranslatableMarkup('Computed string, internal property'))
->setComputed(TRUE)
->setClass(ComputedString::class);
return $properties;
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
SingleInternalPropertyTestFieldItem | Defines the 'Single Internal Property' entity test field type. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.