Epic.php in Drupal PM (Project Management) 4.x
Namespace
Drupal\pm_epic\EntityFile
modules/pm_epic/src/Entity/Epic.phpView source
<?php
namespace Drupal\pm_epic\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 Epic entity.
*
* @ingroup pm_epic
*
* @ContentEntityType(
* id = "pm_epic",
* label = @Translation("Epic"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\pm_epic\EpicListBuilder",
* "views_data" = "Drupal\pm_epic\Entity\EpicViewsData",
*
* "form" = {
* "default" = "Drupal\pm_epic\Form\EpicForm",
* "add" = "Drupal\pm_epic\Form\EpicForm",
* "edit" = "Drupal\pm_epic\Form\EpicForm",
* "delete" = "Drupal\pm_epic\Form\EpicDeleteForm",
* },
* "route_provider" = {
* "html" = "Drupal\pm_epic\EpicHtmlRouteProvider",
* },
* "access" = "Drupal\pm_epic\EpicAccessControlHandler",
* },
* base_table = "pm_epic",
* translatable = FALSE,
* admin_permission = "administer epic entities",
* entity_keys = {
* "id" = "id",
* "label" = "name",
* "uuid" = "uuid",
* "uid" = "user_id",
* "langcode" = "langcode",
* "pm_project" = "pm_project",
* },
* links = {
* "canonical" = "/pm/epic/{pm_epic}",
* "add-form" = "/pm/epic/add",
* "edit-form" = "/pm/epic/{pm_epic}/edit",
* "delete-form" = "/pm/epic/{pm_epic}/delete",
* "collection" = "/pm/epic",
* },
* field_ui_base_route = "pm_epic.settings"
* )
*/
class Epic extends WorkableItem implements EpicInterface {
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['pm_feature'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Feature'))
->setDescription('')
->setSetting('target_type', 'pm_feature')
->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;
}
}