You are here

Feature.php in Drupal PM (Project Management) 4.x

File

modules/pm_feature/src/Entity/Feature.php
View source
<?php

namespace Drupal\pm_feature\Entity;

use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityChangedTrait;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\pm_project\Entity\WorkableItem;
use Drupal\pm_project\Entity\ProjectTrait;
use Drupal\user\UserInterface;

/**
 * Defines the Feature entity.
 *
 * @ingroup pm_feature
 *
 * @ContentEntityType(
 *   id = "pm_feature",
 *   label = @Translation("Feature"),
 *   handlers = {
 *     "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
 *     "list_builder" = "Drupal\pm_feature\FeatureListBuilder",
 *     "views_data" = "Drupal\pm_feature\Entity\FeatureViewsData",
 *
 *     "form" = {
 *       "default" = "Drupal\pm_feature\Form\FeatureForm",
 *       "add" = "Drupal\pm_feature\Form\FeatureForm",
 *       "edit" = "Drupal\pm_feature\Form\FeatureForm",
 *       "delete" = "Drupal\pm_feature\Form\FeatureDeleteForm",
 *     },
 *     "route_provider" = {
 *       "html" = "Drupal\pm_feature\FeatureHtmlRouteProvider",
 *     },
 *     "access" = "Drupal\pm_feature\FeatureAccessControlHandler",
 *   },
 *   base_table = "pm_feature",
 *   translatable = FALSE,
 *   admin_permission = "administer feature entities",
 *   entity_keys = {
 *     "id" = "id",
 *     "label" = "name",
 *     "uuid" = "uuid",
 *     "uid" = "user_id",
 *     "langcode" = "langcode",
 *     "pm_project" = "pm_project",
 *   },
 *   links = {
 *     "canonical" = "/pm/feature/{pm_feature}",
 *     "add-form" = "/pm/feature/add",
 *     "edit-form" = "/pm/feature/{pm_feature}/edit",
 *     "delete-form" = "/pm/feature/{pm_feature}/delete",
 *     "collection" = "/pm/feature",
 *   },
 *   field_ui_base_route = "pm_feature.settings"
 * )
 */
class Feature extends WorkableItem implements FeatureInterface {

  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);
    $fields['pm_story'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Story'))
      ->setDescription('')
      ->setSetting('target_type', 'pm_story')
      ->setSetting('handler', 'default')
      ->setDisplayOptions('view', [
      'label' => 'hidden',
      'type' => 'Issue',
      'weight' => 0,
    ])
      ->setDisplayOptions('form', [
      'type' => 'entity_reference_autocomplete',
      'weight' => 5,
      'settings' => [
        'match_operator' => 'CONTAINS',
        'size' => '60',
        'autocomplete_type' => 'tags',
        'placeholder' => '',
      ],
    ])
      ->setDisplayConfigurable('form', TRUE)
      ->setDisplayConfigurable('view', TRUE)
      ->setRequired(TRUE)
      ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
    return $fields;
  }

}

Classes

Namesort descending Description
Feature Defines the Feature entity.