You are here

public static function MenuLinkItem::propertyDefinitions in Menu Link (Field) 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Field/FieldType/MenuLinkItem.php \Drupal\menu_link\Plugin\Field\FieldType\MenuLinkItem::propertyDefinitions()

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/MenuLinkItem.php, line 145

Class

MenuLinkItem
Defines a menu link field type which stores the link, parent and menu.

Namespace

Drupal\menu_link\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
  $definitions = [];
  $definitions['menu_name'] = DataDefinition::create('string')
    ->setLabel(t('Menu'));
  $definitions['title'] = DataDefinition::create('string')
    ->setLabel(t('Menu link title'));
  $definitions['description'] = DataDefinition::create('string')
    ->setLabel(t('Menu link description'));
  $definitions['parent'] = DataDefinition::create('string')
    ->setLabel(t('Menu link parent'))
    ->setSetting('default', '');
  $definitions['weight'] = DataDefinition::create('integer')
    ->setLabel(t('Menu link weight'));
  return $definitions;
}