Mercurial > hg > cmmr2012-drupal-site
diff core/modules/content_moderation/src/Entity/ContentModerationState.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | c75dbcec494b |
children |
line wrap: on
line diff
--- a/core/modules/content_moderation/src/Entity/ContentModerationState.php Thu Feb 28 13:11:55 2019 +0000 +++ b/core/modules/content_moderation/src/Entity/ContentModerationState.php Thu May 09 15:34:47 2019 +0100 @@ -7,7 +7,7 @@ use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\TypedData\TranslatableInterface; -use Drupal\user\UserInterface; +use Drupal\user\EntityOwnerTrait; /** * Defines the Content moderation state entity. @@ -37,6 +37,7 @@ * "revision" = "revision_id", * "uuid" = "uuid", * "uid" = "uid", + * "owner" = "uid", * "langcode" = "langcode", * } * ) @@ -48,18 +49,18 @@ */ class ContentModerationState extends ContentEntityBase implements ContentModerationStateInterface { + use EntityOwnerTrait; + /** * {@inheritdoc} */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields = parent::baseFieldDefinitions($entity_type); + $fields += static::ownerBaseFieldDefinitions($entity_type); - $fields['uid'] = BaseFieldDefinition::create('entity_reference') + $fields['uid'] ->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['workflow'] = BaseFieldDefinition::create('entity_reference') @@ -99,36 +100,6 @@ } /** - * {@inheritdoc} - */ - public function getOwner() { - return $this->get('uid')->entity; - } - - /** - * {@inheritdoc} - */ - public function getOwnerId() { - return $this->getEntityKey('uid'); - } - - /** - * {@inheritdoc} - */ - public function setOwnerId($uid) { - $this->set('uid', $uid); - return $this; - } - - /** - * {@inheritdoc} - */ - public function setOwner(UserInterface $account) { - $this->set('uid', $account->id()); - return $this; - } - - /** * Creates or updates an entity's moderation state whilst saving that entity. * * @param \Drupal\content_moderation\Entity\ContentModerationState $content_moderation_state @@ -185,10 +156,14 @@ * * @see \Drupal\content_moderation\Entity\ContentModerationState::baseFieldDefinitions() * + * @deprecated The ::getCurrentUserId method is deprecated in 8.6.x and will + * be removed before 9.0.0. + * * @return array * An array of default values. */ public static function getCurrentUserId() { + @trigger_error('The ::getCurrentUserId method is deprecated in 8.6.x and will be removed before 9.0.0.', E_USER_DEPRECATED); return [\Drupal::currentUser()->id()]; }