pm-4.1.x-dev/modules/pm_board/src/Entity/PmBoard.php
modules/pm_board/src/Entity/PmBoard.php
<?php
namespace Drupal\pm_board\Entity;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\pm_board\PmBoardInterface;
use Drupal\pm\PmContentEntityBase;
/**
* Defines the pm board entity class.
*
* @ContentEntityType(
* id = "pm_board",
* label = @Translation("Board"),
* label_collection = @Translation("Boards"),
* label_singular = @Translation("Board"),
* label_plural = @Translation("Boards"),
* label_count = @PluralTranslation(
* singular = "@count Boards",
* plural = "@count Boards",
* ),
* bundle_label = @Translation("Board type"),
* handlers = {
* "list_builder" = "Drupal\pm_board\PmBoardListBuilder",
* "views_data" = "Drupal\views\EntityViewsData",
* "access" = "Drupal\pm_board\PmBoardAccessControlHandler",
* "form" = {
* "add" = "Drupal\pm_board\Form\PmBoardForm",
* "edit" = "Drupal\pm_board\Form\PmBoardForm",
* "delete" = "Drupal\Core\Entity\ContentEntityDeleteForm",
* },
* "route_provider" = {
* "html" = "Drupal\Core\Entity\Routing\AdminHtmlRouteProvider",
* }
* },
* base_table = "pm_board",
* admin_permission = "administer pm board types",
* entity_keys = {
* "id" = "id",
* "bundle" = "bundle",
* "label" = "label",
* "uuid" = "uuid",
* "owner" = "uid",
* },
* links = {
* "collection" = "/admin/pm/board",
* "add-form" = "/pm/board/add/{pm_board_type}",
* "add-page" = "/pm/board/add",
* "canonical" = "/pm/board/{pm_board}",
* "edit-form" = "/pm/board/{pm_board}/edit",
* "delete-form" = "/pm/board/{pm_board}/delete",
* },
* bundle_entity_type = "pm_board_type",
* field_ui_base_route = "entity.pm_board_type.edit_form",
* )
*/
class PmBoard extends PmContentEntityBase implements PmBoardInterface {
/**
* {@inheritdoc}
*/
public static function getPmContentEntityBaseFieldNames() {
return [
'pm_project',
'pm_date',
];
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['pm_board_column_type'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Column Type'))
->setSetting('target_type', 'pm_board_column_type')
->setLabel(t('Column Type'))->setDisplayOptions('form', [
'type' => 'options_select',
'weight' => 15,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayOptions('view', [
'label' => 'above',
'weight' => 15,
])
->setRequired(TRUE)
->setDisplayConfigurable('view', TRUE)
->setCardinality(1);
$fields['pm_board_column'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Columns'))
->setSetting('target_type', 'pm_board_column')
->setLabel(t('Columns'))->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'settings' => [
'match_operator' => 'CONTAINS',
'size' => 60,
'placeholder' => '',
],
'weight' => 15,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayOptions('view', [
'label' => 'above',
'weight' => 15,
])
->setDisplayConfigurable('view', TRUE)
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
->setConstraints([
'UniqueField' => [],
]);
return $fields;
}
}
