DummyAjaxItem.php

Same filename and directory in other branches
  1. 9 core/modules/image/tests/modules/image_module_test/src/Plugin/Field/FieldType/DummyAjaxItem.php
  2. 8.9.x core/modules/image/tests/modules/image_module_test/src/Plugin/Field/FieldType/DummyAjaxItem.php
  3. 11.x core/modules/image/tests/modules/image_module_test/src/Plugin/Field/FieldType/DummyAjaxItem.php

Namespace

Drupal\image_module_test\Plugin\Field\FieldType

File

core/modules/image/tests/modules/image_module_test/src/Plugin/Field/FieldType/DummyAjaxItem.php

View source
<?php

namespace Drupal\image_module_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 a dummy field containing an AJAX handler.
 */
class DummyAjaxItem extends FieldItemBase {
  
  /**
   * {@inheritdoc}
   */
  public static function schema(FieldStorageDefinitionInterface $field_definition) {
    return [
      'columns' => [
        'value' => [
          'type' => 'varchar',
          'length' => 255,
        ],
      ],
    ];
  }
  
  /**
   * {@inheritdoc}
   */
  public function isEmpty() {
    return empty($this->get('value')
      ->getValue());
  }
  
  /**
   * {@inheritdoc}
   */
  public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
    $properties['value'] = DataDefinition::create('string')->setLabel(new TranslatableMarkup('Dummy string value'));
    return $properties;
  }

}

Classes

Title Deprecated Summary
DummyAjaxItem Defines a dummy field containing an AJAX handler.

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