11.2 实体注解

龸龶龴龲龱龯龭龬龩龴龲龱龯龦龥龢龡龠龝龚龖龔龒龏

龚龍龉龆龒龃龁齽齼齺齷core/modules/user/src/Entity/User.php

<?php

namespace Drupal\user\Entity;

use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityChangedTrait;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Language\LanguageInterface;
use Drupal\user\RoleInterface;
use Drupal\user\UserInterface;

/**
 * Defines the user entity class.
 *
 * The base table name here is plural, despite Drupal table naming standards,
 * because "user" is a reserved word in many databases.
 *
 * @ContentEntityType(
 *   id = "user",
 *   label = @Translation("User"),
 *   handlers = {
 *     "storage" = "Drupal\user\UserStorage",
 *     "storage_schema" = "Drupal\user\UserStorageSchema",
 *     "access" = "Drupal\user\UserAccessControlHandler",
 *     "list_builder" = "Drupal\user\UserListBuilder",
 *     "views_data" = "Drupal\user\UserViewsData",
 *     "route_provider" = {
 *       "html" = "Drupal\user\Entity\UserRouteProvider",
 *     },
 *     "form" = {
 *       "default" = "Drupal\user\ProfileForm",
 *       "cancel" = "Drupal\user\Form\UserCancelForm",
 *       "register" = "Drupal\user\RegisterForm"
 *     },
 *     "translation" = "Drupal\user\ProfileTranslationHandler"
 *   },
 *   admin_permission = "administer users",
 *   base_table = "users",
 *   data_table = "users_field_data",
 *   label_callback = "user_format_name",
 *   translatable = TRUE,
 *   entity_keys = {
 *     "id" = "uid",
 *     "langcode" = "langcode",
 *     "uuid" = "uuid"
 *   },
 *   links = {
 *     "canonical" = "/user/{user}",
 *     "edit-form" = "/user/{user}/edit",
 *     "cancel-form" = "/user/{user}/cancel",
 *     "collection" = "/admin/people",
 *   },
 *   field_ui_base_route = "entity.user.admin_form",
 *   common_reference_target = TRUE
 * )
 */
class User extends ContentEntityBase implements UserInterface {
...
}

龠龝黺黶黴龃黱黮黬黨黤

  • id: 龴龲龱龯黡龃點黜黙龏
  • label: 龴龲點黗黶黓UI齺@Translation黐黏黌黈黆黃黁龏
  • handlers: 麽麻麺齺龴麹龴龲龒麷麴麱麮龏
  • admin_permission: 龴龲龒麬麻麪麦龏
  • base_table: 龴龲龒麢麟黐龏
  • data_table: 龴龲龒麜麘黐龏
  • translatable: 龴龲龥麔黈黆黃黁龏
  • entity_keys: 龴龲黨龒麜麐龏
  • links: 黺黶URI麍麌麉麅龒Link麍麌齺麃龥龃鹿麜麐龏
  • field_ui_base_route: 鹼龁UI龒麢鹻鹷鹳龏

本书共79小节:

评论 (写第一个评论)