pm-4.1.x-dev/modules/pm_project/src/Entity/PmProject.php
modules/pm_project/src/Entity/PmProject.php
<?php
namespace Drupal\pm_project\Entity;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\pm_project\PmProjectInterface;
use Drupal\pm\PmContentEntityBase;
/**
* Defines the Project entity class.
*
* @ContentEntityType(
* id = "pm_project",
* label = @Translation("Project"),
* label_collection = @Translation("Projects"),
* label_singular = @Translation("Project"),
* label_plural = @Translation("Projects"),
* label_count = @PluralTranslation(
* singular = "@count Projects",
* plural = "@count Projects",
* ),
* bundle_label = @Translation("Project type"),
* handlers = {
* "list_builder" = "Drupal\pm_project\PmProjectListBuilder",
* "views_data" = "Drupal\views\EntityViewsData",
* "access" = "Drupal\pm_project\PmProjectAccessControlHandler",
* "form" = {
* "add" = "Drupal\pm_project\Form\PmProjectForm",
* "edit" = "Drupal\pm_project\Form\PmProjectForm",
* "delete" = "Drupal\Core\Entity\ContentEntityDeleteForm",
* },
* "route_provider" = {
* "html" = "Drupal\Core\Entity\Routing\AdminHtmlRouteProvider",
* }
* },
* base_table = "pm_project",
* admin_permission = "administer pm project types",
* entity_keys = {
* "id" = "id",
* "bundle" = "bundle",
* "label" = "label",
* "uuid" = "uuid",
* "owner" = "uid",
* },
* links = {
* "collection" = "/admin/pm/project",
* "add-form" = "/pm/project/add/{pm_project_type}",
* "add-page" = "/pm/project/add",
* "canonical" = "/pm/project/{pm_project}",
* "edit-form" = "/pm/project/{pm_project}/edit",
* "delete-form" = "/pm/project/{pm_project}/delete",
* },
* bundle_entity_type = "pm_project_type",
* field_ui_base_route = "entity.pm_project_type.edit_form",
* )
*/
class PmProject extends PmContentEntityBase implements PmProjectInterface {
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['project_key'] = BaseFieldDefinition::create('string')
->setLabel(t('Key'))
->setRequired(TRUE)
->setSetting('max_length', 255)
->setDisplayOptions('form', [
'type' => 'hidden',
'weight' => -5,
])
->setDisplayConfigurable('form', FALSE)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'string',
'weight' => -10,
])
->setDisplayConfigurable('view', TRUE)
->setConstraints([
'UniqueField' => [],
]);
return $fields;
}
/**
* {@inheritdoc}
*/
public static function getPmContentEntityBaseFieldNames() {
return [
'pm_date',
'pm_status',
'pm_priority',
'pm_member_list',
];
}
}
