FieldNote.php in Examples for Developers 3.x
File
modules/field_permission_example/src/Plugin/Field/FieldType/FieldNote.php
View source
<?php
namespace Drupal\field_permission_example\Plugin\Field\FieldType;
use Drupal\Core\Field\FieldItemBase;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\TypedData\DataDefinition;
class FieldNote extends FieldItemBase {
public static function schema(FieldStorageDefinitionInterface $field_definition) {
return [
'columns' => [
'value' => [
'type' => 'text',
'size' => 'normal',
'not null' => FALSE,
],
],
];
}
public function isEmpty() {
$value = $this
->get('value')
->getValue();
return $value === NULL || $value === '';
}
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
$properties['value'] = DataDefinition::create('string')
->setLabel(t('Field Note'));
return $properties;
}
}
Classes
Name |
Description |
FieldNote |
Plugin implementation of the 'field_permission_example' field type. |