GeshiFieldItem.php in GeSHi Filter for syntax highlighting 8.2
File
geshifield/src/Plugin/Field/FieldType/GeshiFieldItem.php
View source
<?php
namespace Drupal\geshifield\Plugin\Field\FieldType;
use Drupal\Core\Field\FieldItemBase;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\TypedData\DataDefinition;
class GeshiFieldItem extends FieldItemBase {
protected static $propertyDefinitions;
public static function schema(FieldStorageDefinitionInterface $field) {
return [
'columns' => [
'sourcecode' => [
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
],
'language' => [
'type' => 'varchar',
'length' => 256,
'not null' => FALSE,
],
],
];
}
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
$properties['sourcecode'] = DataDefinition::create('string')
->setLabel(t('Source code'));
$properties['language'] = DataDefinition::create('string')
->setLabel(t('Syntax highlighting mode'));
return $properties;
}
public function isEmpty() {
$value = $this
->get('sourcecode')
->getValue();
return $value === NULL || $value === '';
}
}