You are here

public static function OfficeHoursItem::propertyDefinitions in Office Hours 8

Defines field item properties.

Properties that are required to constitute a valid, non-empty item should be denoted with \Drupal\Core\TypedData\DataDefinition::setRequired().

Return value

\Drupal\Core\TypedData\DataDefinitionInterface[] An array of property definitions of contained properties, keyed by property name.

Overrides FieldItemInterface::propertyDefinitions

See also

\Drupal\Core\Field\BaseFieldDefinition

File

src/Plugin/Field/FieldType/OfficeHoursItem.php, line 57

Class

OfficeHoursItem
Plugin implementation of the 'office_hours' field type.

Namespace

Drupal\office_hours\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
  $properties['day'] = DataDefinition::create('integer')
    ->setLabel(t('Day'))
    ->setDescription("Stores the day of the week's numeric representation (0=Sun, 6=Sat)");
  $properties['starthours'] = DataDefinition::create('integer')
    ->setLabel(t('Start hours'))
    ->setDescription("Stores the start hours value");
  $properties['endhours'] = DataDefinition::create('integer')
    ->setLabel(t('End hours'))
    ->setDescription("Stores the end hours value");
  $properties['comment'] = DataDefinition::create('string')
    ->setLabel(t('Comment'))
    ->addConstraint('Length', [
    'max' => 255,
  ])
    ->setDescription("Stores the comment");
  return $properties;
}