IdTagItem.php in farmOS 2.x
File
modules/core/id_tag/src/Plugin/Field/FieldType/IdTagItem.php
View source
<?php
namespace Drupal\farm_id_tag\Plugin\Field\FieldType;
use Drupal\Core\Field\FieldItemBase;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\TypedData\DataDefinition;
class IdTagItem extends FieldItemBase {
public static function schema(FieldStorageDefinitionInterface $field_definition) {
return [
'columns' => [
'id' => [
'description' => 'The id of the tag.',
'type' => 'varchar',
'length' => 8192,
'not null' => TRUE,
],
'type' => [
'description' => 'The type of the tag.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
],
'location' => [
'description' => 'The location of the tag.',
'type' => 'varchar',
'length' => 1024,
'not null' => TRUE,
],
],
];
}
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
$properties['id'] = DataDefinition::create('string')
->setLabel(t('ID of the tag'));
$properties['type'] = DataDefinition::create('string')
->setLabel(t('Type of the tag'));
$properties['location'] = DataDefinition::create('string')
->setLabel(t('Location of the tag'));
return $properties;
}
public function isEmpty() {
return ($this->id === NULL || $this->id === '') && ($this->type === NULL || $this->type === '') && ($this->location === NULL || $this->location === '');
}
}
Classes
Name |
Description |
IdTagItem |
Plugin implementation of the 'ID tag' field type. |