PathItem.php 1.28 KB
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Contains \Drupal\path\Plugin\Field\FieldType\PathItem.
6 7
 */

8
namespace Drupal\path\Plugin\Field\FieldType;
9

10
use Drupal\Core\Field\FieldDefinitionInterface;
11
use Drupal\Core\Field\FieldItemBase;
12
use Drupal\Core\TypedData\DataDefinition;
13 14

/**
15
 * Defines the 'path' entity field type.
16
 *
17 18 19
 * @FieldType(
 *   id = "path",
 *   label = @Translation("Path"),
20
 *   description = @Translation("An entity field containing a path alias and related data."),
21
 *   configurable = FALSE
22
 * )
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
 */
class PathItem extends FieldItemBase {

  /**
   * Definitions of the contained properties.
   *
   * @see PathItem::getPropertyDefinitions()
   *
   * @var array
   */
  static $propertyDefinitions;

  /**
   * Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyDefinitions().
   */
  public function getPropertyDefinitions() {
    if (!isset(static::$propertyDefinitions)) {
40 41 42 43 44
      static::$propertyDefinitions['alias'] = DataDefinition::create('string')
        ->setLabel(t('Path alias'));

      static::$propertyDefinitions['pid'] = DataDefinition::create('string')
        ->setLabel(t('Path id'));
45 46 47 48
    }
    return static::$propertyDefinitions;
  }

49 50 51 52 53 54 55
  /**
   * {@inheritdoc}
   */
  public static function schema(FieldDefinitionInterface $field_definition) {
    return array();
  }

56
}