TestObjectItem.php

Same filename in other branches
  1. 9 core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestObjectItem.php
  2. 8.9.x core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestObjectItem.php
  3. 11.x core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestObjectItem.php

Namespace

Drupal\field_test\Plugin\Field\FieldType

File

core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestObjectItem.php

View source
<?php

namespace Drupal\field_test\Plugin\Field\FieldType;

use Drupal\Core\Field\Attribute\FieldType;
use Drupal\Core\Field\FieldItemBase;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\TypedData\DataDefinition;

/**
 * Defines the 'test_object_field' entity field item.
 */
class TestObjectItem extends FieldItemBase {
    
    /**
     * {@inheritdoc}
     */
    public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
        $properties['value'] = DataDefinition::create('any')->setLabel(t('Value'))
            ->setRequired(TRUE);
        return $properties;
    }
    
    /**
     * {@inheritdoc}
     */
    public static function schema(FieldStorageDefinitionInterface $field_definition) {
        return [
            'columns' => [
                'value' => [
                    'description' => 'The object item value.',
                    'type' => 'blob',
                    'not null' => TRUE,
                    'serialize' => TRUE,
                ],
            ],
        ];
    }

}

Classes

Title Deprecated Summary
TestObjectItem Defines the 'test_object_field' entity field item.

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