Commit d7b430a4 authored by alexpott's avatar alexpott

Issue #2707255 by timmillwood, dawehner, amateescu, Berdir: All content...

Issue #2707255 by timmillwood, dawehner, amateescu, Berdir: All content entities should inherit baseFieldDefinitions
parent 899f6473
......@@ -127,16 +127,16 @@ public static function postDelete(EntityStorageInterface $storage, array $entiti
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['fid'] = BaseFieldDefinition::create('integer')
->setLabel(t('Feed ID'))
->setDescription(t('The ID of the aggregator feed.'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
$fields = parent::baseFieldDefinitions($entity_type);
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('UUID'))
->setDescription(t('The aggregator feed UUID.'))
->setReadOnly(TRUE);
$fields['fid']->setLabel(t('Feed ID'))
->setDescription(t('The ID of the aggregator feed.'));
$fields['uuid']->setDescription(t('The aggregator feed UUID.'));
$fields['langcode']->setLabel(t('Language code'))
->setDescription(t('The feed language code.'));
$fields['title'] = BaseFieldDefinition::create('string')
->setLabel(t('Title'))
......@@ -150,17 +150,6 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
->setDisplayConfigurable('form', TRUE)
->addConstraint('FeedTitle');
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language code'))
->setDescription(t('The feed language code.'))
->setDisplayOptions('view', array(
'type' => 'hidden',
))
->setDisplayOptions('form', array(
'type' => 'language_select',
'weight' => 2,
));
$fields['url'] = BaseFieldDefinition::create('uri')
->setLabel(t('URL'))
->setDescription(t('The fully-qualified URL of the feed.'))
......
......@@ -47,11 +47,14 @@ public function label() {
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['iid'] = BaseFieldDefinition::create('integer')
->setLabel(t('Aggregator item ID'))
->setDescription(t('The ID of the feed item.'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
/** @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'))
......@@ -69,10 +72,6 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
->setLabel(t('Title'))
->setDescription(t('The title of the feed item.'));
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language code'))
->setDescription(t('The feed item language code.'));
$fields['link'] = BaseFieldDefinition::create('uri')
->setLabel(t('Link'))
->setDescription(t('The link of the feed item.'))
......
......@@ -144,35 +144,20 @@ public function delete() {
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['id'] = BaseFieldDefinition::create('integer')
->setLabel(t('Custom block ID'))
->setDescription(t('The custom block ID.'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
$fields = parent::baseFieldDefinitions($entity_type);
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('UUID'))
->setDescription(t('The custom block UUID.'))
->setReadOnly(TRUE);
$fields['id']->setLabel(t('Custom block ID'))
->setDescription(t('The custom block ID.'));
$fields['revision_id'] = BaseFieldDefinition::create('integer')
->setLabel(t('Revision ID'))
->setDescription(t('The revision ID.'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
$fields['uuid']->setDescription(t('The custom block UUID.'));
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language'))
->setDescription(t('The custom block language code.'))
->setTranslatable(TRUE)
->setRevisionable(TRUE)
->setDisplayOptions('view', array(
'type' => 'hidden',
))
->setDisplayOptions('form', array(
'type' => 'language_select',
'weight' => 2,
));
$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'))
......@@ -187,12 +172,6 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
->setDisplayConfigurable('form', TRUE)
->addConstraint('UniqueField', []);
$fields['type'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Block type'))
->setDescription(t('The block type.'))
->setSetting('target_type', 'block_content_type');
$fields['revision_log'] = BaseFieldDefinition::create('string_long')
->setLabel(t('Revision log message'))
->setDescription(t('The log entry explaining the changes in this revision.'))
......
......@@ -208,16 +208,18 @@ public function permalink() {
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['cid'] = BaseFieldDefinition::create('integer')
->setLabel(t('Comment ID'))
->setDescription(t('The comment ID.'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
$fields = parent::baseFieldDefinitions($entity_type);
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('UUID'))
->setDescription(t('The comment UUID.'))
->setReadOnly(TRUE);
$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'))
......@@ -229,18 +231,6 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
->setDescription(t('The ID of the entity of which this comment is a reply.'))
->setRequired(TRUE);
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language'))
->setDescription(t('The comment language code.'))
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
'type' => 'hidden',
))
->setDisplayOptions('form', array(
'type' => 'language_select',
'weight' => 2,
));
$fields['subject'] = BaseFieldDefinition::create('string')
->setLabel(t('Subject'))
->setTranslatable(TRUE)
......@@ -312,11 +302,6 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
->setSetting('is_ascii', TRUE)
->setSetting('max_length', EntityTypeInterface::ID_MAX_LENGTH);
$fields['comment_type'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Comment Type'))
->setDescription(t('The comment type.'))
->setSetting('target_type', 'comment_type');
$fields['field_name'] = BaseFieldDefinition::create('string')
->setLabel(t('Comment field name'))
->setDescription(t('The field name through which this comment was added.'))
......
......@@ -130,24 +130,15 @@ public function getPersonalRecipient() {
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['contact_form'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Form ID'))
->setDescription(t('The ID of the associated form.'))
->setSetting('target_type', 'contact_form')
->setRequired(TRUE);
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('UUID'))
->setDescription(t('The message UUID.'))
->setReadOnly(TRUE);
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language'))
->setDescription(t('The message language code.'))
->setDisplayOptions('form', array(
'type' => 'language_select',
'weight' => 2,
));
/** @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"))
......
......@@ -218,20 +218,16 @@ public static function preDelete(EntityStorageInterface $storage, array $entitie
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['fid'] = BaseFieldDefinition::create('integer')
->setLabel(t('File ID'))
->setDescription(t('The file ID.'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('UUID'))
->setDescription(t('The file UUID.'))
->setReadOnly(TRUE);
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language code'))
->setDescription(t('The file language code.'));
/** @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'))
......
......@@ -233,23 +233,20 @@ public static function preDelete(EntityStorageInterface $storage, array $entitie
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['id'] = BaseFieldDefinition::create('integer')
->setLabel(t('Entity ID'))
->setDescription(t('The entity ID for this menu link content entity.'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('UUID'))
->setDescription(t('The content menu link UUID.'))
->setReadOnly(TRUE);
$fields['bundle'] = BaseFieldDefinition::create('string')
->setLabel(t('Bundle'))
/** @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)
->setReadOnly(TRUE);
->setSetting('is_ascii', TRUE);
$fields['title'] = BaseFieldDefinition::create('string')
->setLabel(t('Menu link title'))
......@@ -353,18 +350,6 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
'weight' => -1,
));
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language'))
->setDescription(t('The menu link language code.'))
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
'type' => 'hidden',
))
->setDisplayOptions('form', array(
'type' => 'language_select',
'weight' => 2,
));
$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.'));
......
......@@ -105,22 +105,17 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) {
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['id'] = BaseFieldDefinition::create('integer')
->setLabel(t('ID'))
->setDescription(t('The ID of the shortcut.'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('UUID'))
->setDescription(t('The UUID of the shortcut.'))
->setReadOnly(TRUE);
$fields['shortcut_set'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Shortcut set'))
->setDescription(t('The bundle of the shortcut.'))
->setSetting('target_type', 'shortcut_set')
->setRequired(TRUE);
/** @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'))
......@@ -154,18 +149,6 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
))
->setDisplayConfigurable('form', TRUE);
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language'))
->setDescription(t('The language code of the shortcut.'))
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
'type' => 'hidden',
))
->setDisplayOptions('form', array(
'type' => 'language_select',
'weight' => 2,
));
return $fields;
}
......
......@@ -101,33 +101,18 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) {
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['tid'] = BaseFieldDefinition::create('integer')
->setLabel(t('Term ID'))
->setDescription(t('The term ID.'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('UUID'))
->setDescription(t('The term UUID.'))
->setReadOnly(TRUE);
$fields['vid'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Vocabulary'))
->setDescription(t('The vocabulary to which the term is assigned.'))
->setSetting('target_type', 'taxonomy_vocabulary');
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language'))
->setDescription(t('The term language code.'))
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
'type' => 'hidden',
))
->setDisplayOptions('form', array(
'type' => 'language_select',
'weight' => 2,
));
/** @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'))
......
......@@ -425,21 +425,17 @@ public static function getAnonymousUser() {
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['uid'] = BaseFieldDefinition::create('integer')
->setLabel(t('User ID'))
->setDescription(t('The user ID.'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('UUID'))
->setDescription(t('The user UUID.'))
->setReadOnly(TRUE);
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language code'))
/** @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.'))
->setTranslatable(TRUE);
->setDisplayOptions('form', ['type' => 'hidden']);
$fields['preferred_langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Preferred language code'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment