pm-4.1.x-dev/modules/pm_note/src/Entity/PmNote.php

modules/pm_note/src/Entity/PmNote.php
<?php

namespace Drupal\pm_note\Entity;

use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\pm_note\PmNoteInterface;
use Drupal\pm\PmContentEntityBase;

/**
 * Defines the Note entity class.
 *
 * @ContentEntityType(
 *   id = "pm_note",
 *   label = @Translation("Note"),
 *   label_collection = @Translation("Notes"),
 *   label_singular = @Translation("Note"),
 *   label_plural = @Translation("Notes"),
 *   label_count = @PluralTranslation(
 *     singular = "@count Notes",
 *     plural = "@count Notes",
 *   ),
 *   bundle_label = @Translation("Note type"),
 *   handlers = {
 *     "list_builder" = "Drupal\pm_note\PmNoteListBuilder",
 *     "views_data" = "Drupal\views\EntityViewsData",
 *     "access" = "Drupal\pm_note\PmNoteAccessControlHandler",
 *     "form" = {
 *       "add" = "Drupal\pm_note\Form\PmNoteForm",
 *       "edit" = "Drupal\pm_note\Form\PmNoteForm",
 *       "delete" = "Drupal\Core\Entity\ContentEntityDeleteForm",
 *     },
 *     "route_provider" = {
 *       "html" = "Drupal\Core\Entity\Routing\AdminHtmlRouteProvider",
 *     }
 *   },
 *   base_table = "pm_note",
 *   admin_permission = "administer pm note types",
 *   entity_keys = {
 *     "id" = "id",
 *     "bundle" = "bundle",
 *     "label" = "label",
 *     "uuid" = "uuid",
 *     "owner" = "uid",
 *   },
 *   links = {
 *     "collection" = "/admin/pm/note",
 *     "add-form" = "/pm/note/add/{pm_note_type}",
 *     "add-page" = "/pm/note/add",
 *     "canonical" = "/pm/note/{pm_note}",
 *     "edit-form" = "/pm/note/{pm_note}/edit",
 *     "delete-form" = "/pm/note/{pm_note}/delete",
 *   },
 *   bundle_entity_type = "pm_note_type",
 *   field_ui_base_route = "entity.pm_note_type.edit_form",
 * )
 */
class PmNote extends PmContentEntityBase implements PmNoteInterface {

  /**
   * {@inheritdoc}
   */
  public static function getPmContentEntityBaseFieldNames() {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);
    $fields['pm_reference'] = BaseFieldDefinition::create('dynamic_entity_reference')
      ->setLabel(t('Reference'))
      ->setCardinality(1)
      ->setRequired(TRUE)
      ->setSetting('target_type', [])
      ->setDisplayOptions('form', [
      'type' => 'dynamic_entity_reference_default',
      'weight' => 0,
    ]);
    return $fields;
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc