SubTask.php in Drupal PM (Project Management) 4.x
Namespace
Drupal\pm_sub_task\EntityFile
modules/pm_sub_task/src/Entity/SubTask.phpView source
<?php
namespace Drupal\pm_sub_task\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\pm_project\Entity\ProjectTrait;
use Drupal\pm_project\Entity\WorkableItem;
use Drupal\user\UserInterface;
/**
* Defines the Sub task entity.
*
* @ingroup pm_sub_task
*
* @ContentEntityType(
* id = "pm_sub_task",
* label = @Translation("Sub task"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\pm_sub_task\SubTaskListBuilder",
* "views_data" = "Drupal\pm_sub_task\Entity\SubTaskViewsData",
*
* "form" = {
* "default" = "Drupal\pm_sub_task\Form\SubTaskForm",
* "add" = "Drupal\pm_sub_task\Form\SubTaskForm",
* "edit" = "Drupal\pm_sub_task\Form\SubTaskForm",
* "delete" = "Drupal\pm_sub_task\Form\SubTaskDeleteForm",
* },
* "route_provider" = {
* "html" = "Drupal\pm_sub_task\SubTaskHtmlRouteProvider",
* },
* "access" = "Drupal\pm_sub_task\SubTaskAccessControlHandler",
* },
* base_table = "pm_sub_task",
* translatable = FALSE,
* admin_permission = "administer sub task entities",
* entity_keys = {
* "id" = "id",
* "label" = "name",
* "uuid" = "uuid",
* "uid" = "user_id",
* "langcode" = "langcode",
* "pm_project" = "pm_project",
* },
* links = {
* "canonical" = "/pm/sub_task/{pm_sub_task}",
* "add-form" = "/pm/sub_task/add",
* "edit-form" = "/pm/sub_task/{pm_sub_task}/edit",
* "delete-form" = "/pm/sub_task/{pm_sub_task}/delete",
* "collection" = "/pm/sub_task",
* },
* field_ui_base_route = "pm_sub_task.settings"
* )
*/
class SubTask extends WorkableItem implements SubTaskInterface {
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['pm_issue'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Parent'))
->setDescription('')
->setSetting('target_type', 'pm_issue')
->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(1);
return $fields;
}
}