本文整理汇总了PHP中Drupal\Core\Entity\ContentEntityBase::baseFieldDefinitions方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentEntityBase::baseFieldDefinitions方法的具体用法?PHP ContentEntityBase::baseFieldDefinitions怎么用?PHP ContentEntityBase::baseFieldDefinitions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\ContentEntityBase
的用法示例。
在下文中一共展示了ContentEntityBase::baseFieldDefinitions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['name'] = BaseFieldDefinition::create('string')->setLabel(t('Name'))->setDescription(t('The name of the test entity.'))->setTranslatable(TRUE)->setSetting('max_length', 32)->setDisplayOptions('view', array('label' => 'hidden', 'type' => 'string', 'weight' => -5))->setDisplayOptions('form', array('type' => 'string_textfield', 'weight' => -5));
$fields['created'] = BaseFieldDefinition::create('created')->setLabel(t('Authored on'))->setDescription(t('Time the entity was created'))->setTranslatable(TRUE);
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('User ID'))->setDescription(t('The ID of the associated user.'))->setSetting('target_type', 'user')->setSetting('handler', 'default')->setDefaultValue(array(0 => array('target_id' => 1)))->setTranslatable(TRUE)->setDisplayOptions('form', array('type' => 'entity_reference_autocomplete', 'weight' => -1, 'settings' => array('match_operator' => 'CONTAINS', 'size' => '60', 'placeholder' => '')));
return $fields;
}
示例2: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['uid'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('User'))->setDescription(t('The username of the entity creator.'))->setSetting('target_type', 'user')->setDefaultValueCallback('Drupal\\content_moderation\\Entity\\ContentModerationState::getCurrentUserId')->setTranslatable(TRUE)->setRevisionable(TRUE);
$fields['moderation_state'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Moderation state'))->setDescription(t('The moderation state of the referenced content.'))->setSetting('target_type', 'moderation_state')->setRequired(TRUE)->setTranslatable(TRUE)->setRevisionable(TRUE)->addConstraint('ModerationState', []);
$fields['content_entity_type_id'] = BaseFieldDefinition::create('string')->setLabel(t('Content entity type ID'))->setDescription(t('The ID of the content entity type this moderation state is for.'))->setRequired(TRUE)->setRevisionable(TRUE);
$fields['content_entity_id'] = BaseFieldDefinition::create('integer')->setLabel(t('Content entity ID'))->setDescription(t('The ID of the content entity this moderation state is for.'))->setRequired(TRUE)->setRevisionable(TRUE);
// @todo https://www.drupal.org/node/2779931 Add constraint that enforces
// unique content_entity_type_id, content_entity_id and
// content_entity_revision_id.
$fields['content_entity_revision_id'] = BaseFieldDefinition::create('integer')->setLabel(t('Content entity revision ID'))->setDescription(t('The revision ID of the content entity this moderation state is for.'))->setRequired(TRUE)->setRevisionable(TRUE);
return $fields;
}
示例3: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
$fields = parent::baseFieldDefinitions($entity_type);
$fields['iid']->setLabel(t('Aggregator item ID'))->setDescription(t('The ID of the feed item.'));
$fields['langcode']->setLabel(t('Language code'))->setDescription(t('The feed item language code.'));
$fields['fid'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Source feed'))->setRequired(TRUE)->setDescription(t('The aggregator feed entity associated with this item.'))->setSetting('target_type', 'aggregator_feed')->setDisplayOptions('view', array('label' => 'hidden', 'type' => 'entity_reference_label', 'weight' => 0))->setDisplayConfigurable('form', TRUE);
$fields['title'] = BaseFieldDefinition::create('string')->setLabel(t('Title'))->setDescription(t('The title of the feed item.'));
$fields['link'] = BaseFieldDefinition::create('uri')->setLabel(t('Link'))->setDescription(t('The link of the feed item.'))->setDisplayOptions('view', array('type' => 'hidden'))->setDisplayConfigurable('view', TRUE);
$fields['author'] = BaseFieldDefinition::create('string')->setLabel(t('Author'))->setDescription(t('The author of the feed item.'))->setDisplayOptions('view', array('label' => 'hidden', 'weight' => 3))->setDisplayConfigurable('view', TRUE);
$fields['description'] = BaseFieldDefinition::create('string_long')->setLabel(t('Description'))->setDescription(t('The body of the feed item.'));
$fields['timestamp'] = BaseFieldDefinition::create('created')->setLabel(t('Posted on'))->setDescription(t('Posted date of the feed item, as a Unix timestamp.'))->setDisplayOptions('view', array('label' => 'hidden', 'type' => 'timestamp_ago', 'weight' => 1))->setDisplayConfigurable('view', TRUE);
// @todo Convert to a real UUID field in
// https://www.drupal.org/node/2149851.
$fields['guid'] = BaseFieldDefinition::create('string_long')->setLabel(t('GUID'))->setDescription(t('Unique identifier for the feed item.'));
return $fields;
}
示例4: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
$fields = parent::baseFieldDefinitions($entity_type);
$fields['id']->setDescription(t('The ID of the shortcut.'));
$fields['uuid']->setDescription(t('The UUID of the shortcut.'));
$fields['shortcut_set']->setLabel(t('Shortcut set'))->setDescription(t('The bundle of the shortcut.'));
$fields['langcode']->setDescription(t('The language code of the shortcut.'));
$fields['title'] = BaseFieldDefinition::create('string')->setLabel(t('Name'))->setDescription(t('The name of the shortcut.'))->setRequired(TRUE)->setTranslatable(TRUE)->setSetting('max_length', 255)->setDisplayOptions('form', array('type' => 'string_textfield', 'weight' => -10, 'settings' => array('size' => 40)));
$fields['weight'] = BaseFieldDefinition::create('integer')->setLabel(t('Weight'))->setDescription(t('Weight among shortcuts in the same shortcut set.'));
$fields['link'] = BaseFieldDefinition::create('link')->setLabel(t('Path'))->setDescription(t('The location this shortcut points to.'))->setRequired(TRUE)->setSettings(array('link_type' => LinkItemInterface::LINK_INTERNAL, 'title' => DRUPAL_DISABLED))->setDisplayOptions('form', array('type' => 'link_default', 'weight' => 0))->setDisplayConfigurable('form', TRUE);
return $fields;
}
示例5: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['title'] = BaseFieldDefinition::create('string')->setLabel(t('Title'))->setRequired(TRUE)->setTranslatable(TRUE)->setRevisionable(TRUE)->setSetting('max_length', 255)->setDisplayOptions('view', array('label' => 'hidden', 'type' => 'string', 'weight' => -5))->setDisplayOptions('form', array('type' => 'string_textfield', 'weight' => -5))->setDisplayConfigurable('form', TRUE);
$fields['uid'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Authored by'))->setDescription(t('The username of the content author.'))->setRevisionable(TRUE)->setSetting('target_type', 'user')->setDefaultValueCallback('Drupal\\node\\Entity\\Node::getCurrentUserId')->setTranslatable(TRUE)->setDisplayOptions('view', array('label' => 'hidden', 'type' => 'author', 'weight' => 0))->setDisplayOptions('form', array('type' => 'entity_reference_autocomplete', 'weight' => 5, 'settings' => array('match_operator' => 'CONTAINS', 'size' => '60', 'placeholder' => '')))->setDisplayConfigurable('form', TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')->setLabel(t('Publishing status'))->setDescription(t('A boolean indicating whether the node is published.'))->setRevisionable(TRUE)->setTranslatable(TRUE)->setDefaultValue(TRUE);
$fields['created'] = BaseFieldDefinition::create('created')->setLabel(t('Authored on'))->setDescription(t('The time that the node was created.'))->setRevisionable(TRUE)->setTranslatable(TRUE)->setDisplayOptions('view', array('label' => 'hidden', 'type' => 'timestamp', 'weight' => 0))->setDisplayOptions('form', array('type' => 'datetime_timestamp', 'weight' => 10))->setDisplayConfigurable('form', TRUE);
$fields['changed'] = BaseFieldDefinition::create('changed')->setLabel(t('Changed'))->setDescription(t('The time that the node was last edited.'))->setRevisionable(TRUE)->setTranslatable(TRUE);
$fields['promote'] = BaseFieldDefinition::create('boolean')->setLabel(t('Promoted to front page'))->setRevisionable(TRUE)->setTranslatable(TRUE)->setDefaultValue(TRUE)->setDisplayOptions('form', array('type' => 'boolean_checkbox', 'settings' => array('display_label' => TRUE), 'weight' => 15))->setDisplayConfigurable('form', TRUE);
$fields['sticky'] = BaseFieldDefinition::create('boolean')->setLabel(t('Sticky at top of lists'))->setRevisionable(TRUE)->setTranslatable(TRUE)->setDefaultValue(FALSE)->setDisplayOptions('form', array('type' => 'boolean_checkbox', 'settings' => array('display_label' => TRUE), 'weight' => 16))->setDisplayConfigurable('form', TRUE);
$fields['revision_timestamp'] = BaseFieldDefinition::create('created')->setLabel(t('Revision timestamp'))->setDescription(t('The time that the current revision was created.'))->setQueryable(FALSE)->setRevisionable(TRUE);
$fields['revision_uid'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Revision user ID'))->setDescription(t('The user ID of the author of the current revision.'))->setSetting('target_type', 'user')->setQueryable(FALSE)->setRevisionable(TRUE);
$fields['revision_log'] = BaseFieldDefinition::create('string_long')->setLabel(t('Revision log message'))->setDescription(t('Briefly describe the changes you have made.'))->setRevisionable(TRUE)->setDefaultValue('')->setDisplayOptions('form', array('type' => 'string_textarea', 'weight' => 25, 'settings' => array('rows' => 4)));
$fields['revision_translation_affected'] = BaseFieldDefinition::create('boolean')->setLabel(t('Revision translation affected'))->setDescription(t('Indicates if the last edit of a translation belongs to current revision.'))->setReadOnly(TRUE)->setRevisionable(TRUE)->setTranslatable(TRUE);
return $fields;
}
示例6: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['name'] = BaseFieldDefinition::create('string')->setLabel(t('Name'))->setDescription(t('The name of the test entity.'))->setTranslatable(TRUE)->setSetting('max_length', 32)->setDisplayOptions('view', ['label' => 'hidden', 'type' => 'string', 'weight' => -5])->setDisplayOptions('form', ['type' => 'string_textfield', 'weight' => -5]);
return $fields;
}
示例7: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
$fields = parent::baseFieldDefinitions($entity_type);
$fields['tid']->setLabel(t('Term ID'))->setDescription(t('The term ID.'));
$fields['uuid']->setDescription(t('The term UUID.'));
$fields['vid']->setLabel(t('Vocabulary'))->setDescription(t('The vocabulary to which the term is assigned.'));
$fields['langcode']->setDescription(t('The term language code.'));
$fields['name'] = BaseFieldDefinition::create('string')->setLabel(t('Name'))->setDescription(t('The term name.'))->setTranslatable(TRUE)->setRequired(TRUE)->setSetting('max_length', 255)->setDisplayOptions('view', array('label' => 'hidden', 'type' => 'string', 'weight' => -5))->setDisplayOptions('form', array('type' => 'string_textfield', 'weight' => -5))->setDisplayConfigurable('form', TRUE);
$fields['description'] = BaseFieldDefinition::create('text_long')->setLabel(t('Description'))->setDescription(t('A description of the term.'))->setTranslatable(TRUE)->setDisplayOptions('view', array('label' => 'hidden', 'type' => 'text_default', 'weight' => 0))->setDisplayConfigurable('view', TRUE)->setDisplayOptions('form', array('type' => 'text_textfield', 'weight' => 0))->setDisplayConfigurable('form', TRUE);
$fields['weight'] = BaseFieldDefinition::create('integer')->setLabel(t('Weight'))->setDescription(t('The weight of this term in relation to other terms.'))->setDefaultValue(0);
$fields['parent'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Term Parents'))->setDescription(t('The parents of this term.'))->setSetting('target_type', 'taxonomy_term')->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)->setCustomStorage(TRUE);
$fields['changed'] = BaseFieldDefinition::create('changed')->setLabel(t('Changed'))->setDescription(t('The time that the term was last edited.'))->setTranslatable(TRUE);
return $fields;
}
示例8: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['title'] = BaseFieldDefinition::create('string')->setLabel(t('Title'))->setDescription(t('The schedule title.'))->setRequired(TRUE)->setTranslatable(TRUE)->setSettings(['default_value' => '', 'max_length' => 255])->setDisplayOptions('view', ['label' => 'hidden', 'type' => 'string', 'weight' => -5])->setDisplayOptions('form', ['type' => 'string_textfield', 'weight' => -5])->setDisplayConfigurable('form', TRUE);
$fields['path'] = BaseFieldDefinition::create('path')->setLabel(t('URL alias'))->setDescription(t('The schedule URL alias.'))->setTranslatable(TRUE)->setDisplayOptions('form', ['type' => 'path', 'weight' => 30])->setDisplayConfigurable('form', TRUE)->setCustomStorage(TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')->setLabel(t('Published'))->setDescription(t('Whether the schedule is published.'))->setDefaultValue(TRUE)->setTranslatable(TRUE)->setDisplayConfigurable('form', TRUE);
$fields['created'] = BaseFieldDefinition::create('created')->setLabel(t('Created'))->setDescription(t('The time when the schedule was created.'))->setTranslatable(TRUE)->setDisplayConfigurable('view', TRUE)->setDisplayOptions('form', ['type' => 'datetime_timestamp', 'weight' => 10])->setDisplayConfigurable('form', TRUE);
$fields['changed'] = BaseFieldDefinition::create('changed')->setLabel(t('Changed'))->setDescription(t('The time when the schedule was last edited.'))->setTranslatable(TRUE);
return $fields;
}
示例9: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['uid'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Author'))->setDescription(t('The session author.'))->setSetting('target_type', 'user')->setSetting('handler', 'default')->setDefaultValueCallback('Drupal\\conference_sessions\\Entity\\Session::getCurrentUserId')->setTranslatable(TRUE)->setDisplayConfigurable('view', TRUE)->setDisplayOptions('form', ['type' => 'entity_reference_autocomplete', 'weight' => 5])->setDisplayConfigurable('form', TRUE);
$fields['title'] = BaseFieldDefinition::create('string')->setLabel(t('Title'))->setDescription(t('The session title.'))->setRequired(TRUE)->setTranslatable(TRUE)->setSettings(['default_value' => '', 'max_length' => 255])->setDisplayOptions('view', ['label' => 'hidden', 'type' => 'string', 'weight' => -5])->setDisplayOptions('form', ['type' => 'string_textfield', 'weight' => -5])->setDisplayConfigurable('form', TRUE);
$fields['path'] = BaseFieldDefinition::create('path')->setLabel(t('URL alias'))->setDescription(t('The session URL alias.'))->setTranslatable(TRUE)->setDisplayOptions('form', ['type' => 'path', 'weight' => 30])->setDisplayConfigurable('form', TRUE)->setCustomStorage(TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')->setLabel(t('Published'))->setDescription(t('Whether the session is published.'))->setDefaultValue(TRUE)->setTranslatable(TRUE)->setDisplayConfigurable('form', TRUE);
$fields['created'] = BaseFieldDefinition::create('created')->setLabel(t('Created'))->setDescription(t('The time when the session was created.'))->setTranslatable(TRUE)->setDisplayConfigurable('view', TRUE)->setDisplayOptions('form', ['type' => 'datetime_timestamp', 'weight' => 10])->setDisplayConfigurable('form', TRUE);
$fields['changed'] = BaseFieldDefinition::create('changed')->setLabel(t('Changed'))->setDescription(t('The time when the session was last edited.'))->setTranslatable(TRUE);
$fields['room'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Room'))->setDescription(t('The session room.'))->setSetting('target_type', 'sessions_room')->setSetting('handler', 'default')->setTranslatable(TRUE)->setDisplayConfigurable('view', TRUE)->setDisplayOptions('form', ['type' => 'entity_reference_autocomplete', 'weight' => 5])->setDisplayConfigurable('form', TRUE);
return $fields;
}
示例10: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
$fields = parent::baseFieldDefinitions($entity_type);
$fields['contact_form']->setLabel(t('Form ID'))->setDescription(t('The ID of the associated form.'));
$fields['uuid']->setDescription(t('The message UUID.'));
$fields['langcode']->setDescription(t('The message language code.'));
$fields['name'] = BaseFieldDefinition::create('string')->setLabel(t("The sender's name"))->setDescription(t('The name of the person that is sending the contact message.'));
$fields['mail'] = BaseFieldDefinition::create('email')->setLabel(t("The sender's email"))->setDescription(t('The email of the person that is sending the contact message.'));
// The subject of the contact message.
$fields['subject'] = BaseFieldDefinition::create('string')->setLabel(t('Subject'))->setRequired(TRUE)->setSetting('max_length', 100)->setDisplayOptions('form', array('type' => 'string_textfield', 'weight' => -10))->setDisplayConfigurable('form', TRUE);
// The text of the contact message.
$fields['message'] = BaseFieldDefinition::create('string_long')->setLabel(t('Message'))->setRequired(TRUE)->setDisplayOptions('form', array('type' => 'string_textarea', 'weight' => 0, 'settings' => array('rows' => 12)))->setDisplayConfigurable('form', TRUE)->setDisplayOptions('view', array('type' => 'string', 'weight' => 0, 'label' => 'above'))->setDisplayConfigurable('view', TRUE);
$fields['copy'] = BaseFieldDefinition::create('boolean')->setLabel(t('Copy'))->setDescription(t('Whether to send a copy of the message to the sender.'));
$fields['recipient'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Recipient ID'))->setDescription(t('The ID of the recipient user for personal contact messages.'))->setSetting('target_type', 'user');
return $fields;
}
示例11: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
$fields = parent::baseFieldDefinitions($entity_type);
$fields['id']->setLabel(t('Entity ID'))->setDescription(t('The entity ID for this menu link content entity.'));
$fields['uuid']->setDescription(t('The content menu link UUID.'));
$fields['langcode']->setDescription(t('The menu link language code.'));
$fields['bundle']->setDescription(t('The content menu link bundle.'))->setSetting('max_length', EntityTypeInterface::BUNDLE_MAX_LENGTH)->setSetting('is_ascii', TRUE);
$fields['title'] = BaseFieldDefinition::create('string')->setLabel(t('Menu link title'))->setDescription(t('The text to be used for this link in the menu.'))->setRequired(TRUE)->setTranslatable(TRUE)->setSetting('max_length', 255)->setDisplayOptions('view', array('label' => 'hidden', 'type' => 'string', 'weight' => -5))->setDisplayOptions('form', array('type' => 'string_textfield', 'weight' => -5))->setDisplayConfigurable('form', TRUE);
$fields['description'] = BaseFieldDefinition::create('string')->setLabel(t('Description'))->setDescription(t('Shown when hovering over the menu link.'))->setTranslatable(TRUE)->setSetting('max_length', 255)->setDisplayOptions('view', array('label' => 'hidden', 'type' => 'string', 'weight' => 0))->setDisplayOptions('form', array('type' => 'string_textfield', 'weight' => 0));
$fields['menu_name'] = BaseFieldDefinition::create('string')->setLabel(t('Menu name'))->setDescription(t('The menu name. All links with the same menu name (such as "tools") are part of the same menu.'))->setDefaultValue('tools')->setSetting('is_ascii', TRUE);
$fields['link'] = BaseFieldDefinition::create('link')->setLabel(t('Link'))->setDescription(t('The location this menu link points to.'))->setRequired(TRUE)->setSettings(array('link_type' => LinkItemInterface::LINK_GENERIC, 'title' => DRUPAL_DISABLED))->setDisplayOptions('form', array('type' => 'link_default', 'weight' => -2));
$fields['external'] = BaseFieldDefinition::create('boolean')->setLabel(t('External'))->setDescription(t('A flag to indicate if the link points to a full URL starting with a protocol, like http:// (1 = external, 0 = internal).'))->setDefaultValue(FALSE);
$fields['rediscover'] = BaseFieldDefinition::create('boolean')->setLabel(t('Indicates whether the menu link should be rediscovered'))->setDefaultValue(FALSE);
$fields['weight'] = BaseFieldDefinition::create('integer')->setLabel(t('Weight'))->setDescription(t('Link weight among links in the same menu at the same depth. In the menu, the links with high weight will sink and links with a low weight will be positioned nearer the top.'))->setDefaultValue(0)->setDisplayOptions('view', array('label' => 'hidden', 'type' => 'integer', 'weight' => 0))->setDisplayOptions('form', array('type' => 'number', 'weight' => 20));
$fields['expanded'] = BaseFieldDefinition::create('boolean')->setLabel(t('Show as expanded'))->setDescription(t('If selected and this menu link has children, the menu will always appear expanded.'))->setDefaultValue(FALSE)->setDisplayOptions('view', array('label' => 'hidden', 'type' => 'boolean', 'weight' => 0))->setDisplayOptions('form', array('settings' => array('display_label' => TRUE), 'weight' => 0));
$fields['enabled'] = BaseFieldDefinition::create('boolean')->setLabel(t('Enabled'))->setDescription(t('A flag for whether the link should be enabled in menus or hidden.'))->setDefaultValue(TRUE)->setDisplayOptions('view', array('label' => 'hidden', 'type' => 'boolean', 'weight' => 0))->setDisplayOptions('form', array('settings' => array('display_label' => TRUE), 'weight' => -1));
$fields['parent'] = BaseFieldDefinition::create('string')->setLabel(t('Parent plugin ID'))->setDescription(t('The ID of the parent menu link plugin, or empty string when at the top level of the hierarchy.'));
$fields['changed'] = BaseFieldDefinition::create('changed')->setLabel(t('Changed'))->setDescription(t('The time that the menu link was last edited.'))->setTranslatable(TRUE);
return $fields;
}
示例12: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
$fields = parent::baseFieldDefinitions($entity_type);
$fields['uid']->setLabel(t('User ID'))
->setDescription(t('The user ID.'));
$fields['uuid']->setDescription(t('The user UUID.'));
$fields['langcode']->setLabel(t('Language code'))
->setDescription(t('The user language code.'))
->setDisplayOptions('form', ['type' => 'hidden']);
$fields['preferred_langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Preferred language code'))
->setDescription(t("The user's preferred language code for receiving emails and viewing the site."))
// @todo: Define this via an options provider once
// https://www.drupal.org/node/2329937 is completed.
->addPropertyConstraints('value', array(
'AllowedValues' => array('callback' => __CLASS__ . '::getAllowedConfigurableLanguageCodes'),
));
$fields['preferred_admin_langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Preferred admin language code'))
->setDescription(t("The user's preferred language code for viewing administration pages."))
// @todo: A default value of NULL is ignored, so we have to specify
// an empty field item structure instead. Fix this in
// https://www.drupal.org/node/2318605.
->setDefaultValue(array(0 => array ('value' => NULL)))
// @todo: Define this via an options provider once
// https://www.drupal.org/node/2329937 is completed.
->addPropertyConstraints('value', array(
'AllowedValues' => array('callback' => __CLASS__ . '::getAllowedConfigurableLanguageCodes'),
));
// The name should not vary per language. The username is the visual
// identifier for a user and needs to be consistent in all languages.
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t('The name of this user.'))
->setRequired(TRUE)
->setConstraints(array(
// No Length constraint here because the UserName constraint also covers
// that.
'UserName' => array(),
'UserNameUnique' => array(),
));
$fields['name']->getItemDefinition()->setClass('\Drupal\user\UserNameItem');
$fields['pass'] = BaseFieldDefinition::create('password')
->setLabel(t('Password'))
->setDescription(t('The password of this user (hashed).'))
->addConstraint('ProtectedUserField');
$fields['mail'] = BaseFieldDefinition::create('email')
->setLabel(t('Email'))
->setDescription(t('The email of this user.'))
->setDefaultValue('')
->addConstraint('UserMailUnique')
->addConstraint('UserMailRequired')
->addConstraint('ProtectedUserField');
$fields['timezone'] = BaseFieldDefinition::create('string')
->setLabel(t('Timezone'))
->setDescription(t('The timezone of this user.'))
->setSetting('max_length', 32)
// @todo: Define this via an options provider once
// https://www.drupal.org/node/2329937 is completed.
->addPropertyConstraints('value', array(
'AllowedValues' => array('callback' => __CLASS__ . '::getAllowedTimezones'),
));
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('User status'))
->setDescription(t('Whether the user is active or blocked.'))
->setDefaultValue(FALSE);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time that the user was created.'));
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
->setDescription(t('The time that the user was last edited.'))
->setTranslatable(TRUE);
$fields['access'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('Last access'))
->setDescription(t('The time that the user last accessed the site.'))
->setDefaultValue(0);
$fields['login'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('Last login'))
->setDescription(t('The time that the user last logged in.'))
->setDefaultValue(0);
$fields['init'] = BaseFieldDefinition::create('email')
//.........这里部分代码省略.........
示例13: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
$fields = parent::baseFieldDefinitions($entity_type);
$fields['fid']->setLabel(t('File ID'))->setDescription(t('The file ID.'));
$fields['uuid']->setDescription(t('The file UUID.'));
$fields['langcode']->setLabel(t('Language code'))->setDescription(t('The file language code.'));
$fields['uid'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('User ID'))->setDescription(t('The user ID of the file.'))->setSetting('target_type', 'user');
$fields['filename'] = BaseFieldDefinition::create('string')->setLabel(t('Filename'))->setDescription(t('Name of the file with no path components.'));
$fields['uri'] = BaseFieldDefinition::create('uri')->setLabel(t('URI'))->setDescription(t('The URI to access the file (either local or remote).'))->setSetting('max_length', 255)->setSetting('case_sensitive', TRUE)->addConstraint('FileUriUnique');
$fields['filemime'] = BaseFieldDefinition::create('string')->setLabel(t('File MIME type'))->setSetting('is_ascii', TRUE)->setDescription(t("The file's MIME type."));
$fields['filesize'] = BaseFieldDefinition::create('integer')->setLabel(t('File size'))->setDescription(t('The size of the file in bytes.'))->setSetting('unsigned', TRUE)->setSetting('size', 'big');
$fields['status'] = BaseFieldDefinition::create('boolean')->setLabel(t('Status'))->setDescription(t('The status of the file, temporary (FALSE) and permanent (TRUE).'))->setDefaultValue(FALSE);
$fields['created'] = BaseFieldDefinition::create('created')->setLabel(t('Created'))->setDescription(t('The timestamp that the file was created.'));
$fields['changed'] = BaseFieldDefinition::create('changed')->setLabel(t('Changed'))->setDescription(t('The timestamp that the file was last changed.'));
return $fields;
}
示例14: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
$fields = parent::baseFieldDefinitions($entity_type);
$fields['cid']->setLabel(t('Comment ID'))->setDescription(t('The comment ID.'));
$fields['uuid']->setDescription(t('The comment UUID.'));
$fields['comment_type']->setLabel(t('Comment Type'))->setDescription(t('The comment type.'));
$fields['langcode']->setDescription(t('The comment language code.'));
$fields['pid'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Parent ID'))->setDescription(t('The parent comment ID if this is a reply to a comment.'))->setSetting('target_type', 'comment');
$fields['entity_id'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Entity ID'))->setDescription(t('The ID of the entity of which this comment is a reply.'))->setRequired(TRUE);
$fields['subject'] = BaseFieldDefinition::create('string')->setLabel(t('Subject'))->setTranslatable(TRUE)->setSetting('max_length', 64)->setDisplayOptions('form', array('type' => 'string_textfield', 'weight' => 10))->setDisplayConfigurable('form', TRUE);
$fields['uid'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('User ID'))->setDescription(t('The user ID of the comment author.'))->setTranslatable(TRUE)->setSetting('target_type', 'user')->setDefaultValue(0);
$fields['name'] = BaseFieldDefinition::create('string')->setLabel(t('Name'))->setDescription(t("The comment author's name."))->setTranslatable(TRUE)->setSetting('max_length', 60)->setDefaultValue('');
$fields['mail'] = BaseFieldDefinition::create('email')->setLabel(t('Email'))->setDescription(t("The comment author's email address."))->setTranslatable(TRUE);
$fields['homepage'] = BaseFieldDefinition::create('uri')->setLabel(t('Homepage'))->setDescription(t("The comment author's home page address."))->setTranslatable(TRUE)->setSetting('max_length', 255);
$fields['hostname'] = BaseFieldDefinition::create('string')->setLabel(t('Hostname'))->setDescription(t("The comment author's hostname."))->setTranslatable(TRUE)->setSetting('max_length', 128);
$fields['created'] = BaseFieldDefinition::create('created')->setLabel(t('Created'))->setDescription(t('The time that the comment was created.'))->setTranslatable(TRUE);
$fields['changed'] = BaseFieldDefinition::create('changed')->setLabel(t('Changed'))->setDescription(t('The time that the comment was last edited.'))->setTranslatable(TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')->setLabel(t('Publishing status'))->setDescription(t('A boolean indicating whether the comment is published.'))->setTranslatable(TRUE)->setDefaultValue(TRUE);
$fields['thread'] = BaseFieldDefinition::create('string')->setLabel(t('Thread place'))->setDescription(t("The alphadecimal representation of the comment's place in a thread, consisting of a base 36 string prefixed by an integer indicating its length."))->setSetting('max_length', 255);
$fields['entity_type'] = BaseFieldDefinition::create('string')->setLabel(t('Entity type'))->setDescription(t('The entity type to which this comment is attached.'))->setSetting('is_ascii', TRUE)->setSetting('max_length', EntityTypeInterface::ID_MAX_LENGTH);
$fields['field_name'] = BaseFieldDefinition::create('string')->setLabel(t('Comment field name'))->setDescription(t('The field name through which this comment was added.'))->setSetting('is_ascii', TRUE)->setSetting('max_length', FieldStorageConfig::NAME_MAX_LENGTH);
return $fields;
}
示例15: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
$fields = parent::baseFieldDefinitions($entity_type);
$fields['id']->setLabel(t('Custom block ID'))->setDescription(t('The custom block ID.'));
$fields['uuid']->setDescription(t('The custom block UUID.'));
$fields['revision_id']->setDescription(t('The revision ID.'));
$fields['langcode']->setDescription(t('The custom block language code.'));
$fields['type']->setLabel(t('Block type'))->setDescription(t('The block type.'));
$fields['info'] = BaseFieldDefinition::create('string')->setLabel(t('Block description'))->setDescription(t('A brief description of your block.'))->setRevisionable(TRUE)->setTranslatable(TRUE)->setRequired(TRUE)->setDisplayOptions('form', array('type' => 'string_textfield', 'weight' => -5))->setDisplayConfigurable('form', TRUE)->addConstraint('UniqueField', []);
$fields['revision_log'] = BaseFieldDefinition::create('string_long')->setLabel(t('Revision log message'))->setDescription(t('The log entry explaining the changes in this revision.'))->setRevisionable(TRUE);
$fields['changed'] = BaseFieldDefinition::create('changed')->setLabel(t('Changed'))->setDescription(t('The time that the custom block was last edited.'))->setTranslatable(TRUE)->setRevisionable(TRUE);
$fields['revision_created'] = BaseFieldDefinition::create('created')->setLabel(t('Revision create time'))->setDescription(t('The time that the current revision was created.'))->setRevisionable(TRUE);
$fields['revision_user'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Revision user'))->setDescription(t('The user ID of the author of the current revision.'))->setSetting('target_type', 'user')->setRevisionable(TRUE);
$fields['revision_translation_affected'] = BaseFieldDefinition::create('boolean')->setLabel(t('Revision translation affected'))->setDescription(t('Indicates if the last edit of a translation belongs to current revision.'))->setReadOnly(TRUE)->setRevisionable(TRUE)->setTranslatable(TRUE);
return $fields;
}