BynderMetadataItem.php in Bynder 8.2
File
src/Plugin/Field/FieldType/BynderMetadataItem.php
View source
<?php
namespace Drupal\bynder\Plugin\Field\FieldType;
use Drupal\Core\Field\FieldItemBase;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\TypedData\DataDefinition;
class BynderMetadataItem extends FieldItemBase {
const METADATA_FIELD_NAME = 'bynder_metadata';
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
$properties['value'] = DataDefinition::create('string')
->setLabel(t('JSON Value'));
return $properties;
}
public static function schema(FieldStorageDefinitionInterface $field_definition) {
$schema['columns']['value']['type'] = 'text';
$schema['columns']['value']['size'] = 'normal';
return $schema;
}
public function isEmpty() {
return $this->value === NULL || $this->value === '';
}
}