SubscriptionItem.php in Simplenews 3.x
File
src/Plugin/Field/FieldType/SubscriptionItem.php
View source
<?php
namespace Drupal\simplenews\Plugin\Field\FieldType;
use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\TypedData\DataDefinition;
class SubscriptionItem extends EntityReferenceItem {
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
$properties = parent::propertyDefinitions($field_definition);
$properties['status'] = DataDefinition::create('integer')
->setLabel(t('Status'))
->setSetting('unsigned', TRUE);
$properties['timestamp'] = DataDefinition::create('timestamp')
->setLabel(t('Timestamp'));
$properties['source'] = DataDefinition::create('string')
->setLabel(t('Source'));
return $properties;
}
public static function schema(FieldStorageDefinitionInterface $field_definition) {
$schema = parent::schema($field_definition);
$schema['columns']['status'] = [
'description' => 'A flag indicating whether the user is unsubscribed (0), subscribed (1) or unconfirmed (2).',
'type' => 'int',
'size' => 'tiny',
'not null' => FALSE,
];
$schema['columns']['timestamp'] = [
'description' => 'UNIX timestamp of when the user is (un)subscribed.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
];
$schema['columns']['source'] = [
'description' => 'The source via which the user is (un)subscription.',
'type' => 'varchar',
'length' => 24,
'not null' => FALSE,
];
return $schema;
}
}
Classes
Name |
Description |
SubscriptionItem |
Defines the 'subscription' entity field type (extended entity_reference). |