Unverified Commit 0f56ba98 authored by alexpott's avatar alexpott
Browse files

Issue #3029405 by amateescu, hchonov: Clean up documentation and type hints...

Issue #3029405 by amateescu, hchonov: Clean up documentation and type hints that don't need to mention both EntityInterface and another specialized interface anymore
parent aaf13e23
......@@ -164,7 +164,7 @@ protected function initFieldValues(ContentEntityInterface $entity, array $values
/**
* Checks whether any entity revision is translated.
*
* @param \Drupal\Core\Entity\EntityInterface|\Drupal\Core\Entity\TranslatableInterface $entity
* @param \Drupal\Core\Entity\TranslatableInterface $entity
* The entity object to be checked.
*
* @return bool
......@@ -186,7 +186,7 @@ protected function isAnyRevisionTranslated(TranslatableInterface $entity) {
* the entity has any translation in the storage and thus should be considered
* as multilingual.
*
* @param \Drupal\Core\Entity\EntityInterface|\Drupal\Core\Entity\TranslatableInterface $entity
* @param \Drupal\Core\Entity\TranslatableInterface $entity
* The entity object to be checked.
*
* @return bool
......
......@@ -10,13 +10,13 @@ interface RevisionableStorageInterface extends EntityStorageInterface {
/**
* Creates a new revision starting off from the specified entity object.
*
* @param \Drupal\Core\Entity\EntityInterface|\Drupal\Core\Entity\RevisionableInterface $entity
* @param \Drupal\Core\Entity\RevisionableInterface $entity
* The revisionable entity object being modified.
* @param bool $default
* (optional) Whether the new revision should be marked as default. Defaults
* to TRUE.
*
* @return \Drupal\Core\Entity\EntityInterface|\Drupal\Core\Entity\RevisionableInterface
* @return \Drupal\Core\Entity\RevisionableInterface
* A new entity revision object.
*/
public function createRevision(RevisionableInterface $entity, $default = TRUE);
......@@ -27,7 +27,7 @@ public function createRevision(RevisionableInterface $entity, $default = TRUE);
* @param int $revision_id
* The revision ID.
*
* @return \Drupal\Core\Entity\EntityInterface|null
* @return \Drupal\Core\Entity\RevisionableInterface|null
* The specified entity revision or NULL if not found.
*/
public function loadRevision($revision_id);
......@@ -38,7 +38,7 @@ public function loadRevision($revision_id);
* @param array $revision_ids
* An array of revision IDs to load.
*
* @return \Drupal\Core\Entity\EntityInterface[]
* @return \Drupal\Core\Entity\RevisionableInterface[]
* An array of entity revisions keyed by their revision ID, or an empty
* array if none found.
*/
......
......@@ -13,7 +13,7 @@ interface TranslatableRevisionableStorageInterface extends TranslatableStorageIn
* When dealing with a translatable entity, this will merge the default
* revision with the active translation of the passed entity.
*
* @param \Drupal\Core\Entity\EntityInterface|\Drupal\Core\Entity\RevisionableInterface $entity
* @param \Drupal\Core\Entity\RevisionableInterface $entity
* The revisionable entity object being modified.
* @param bool $default
* (optional) Whether the new revision should be marked as default. Defaults
......@@ -24,7 +24,7 @@ interface TranslatableRevisionableStorageInterface extends TranslatableStorageIn
* TRUE if the provided entity is the default translation and untranslatable
* fields should only affect the default translation, FALSE otherwise.
*
* @return \Drupal\Core\Entity\EntityInterface|\Drupal\Core\Entity\RevisionableInterface
* @return \Drupal\Core\Entity\TranslatableRevisionableInterface
* A new translatable entity revision object.
*/
public function createRevision(RevisionableInterface $entity, $default = TRUE, $keep_untranslatable_fields = NULL);
......
......@@ -152,12 +152,12 @@ public function convert($value, $definition, $name, array $defaults) {
/**
* Returns the ID of the latest revision translation of the specified entity.
*
* @param \Drupal\Core\Entity\EntityInterface|\Drupal\Core\Entity\RevisionableInterface $entity
* @param \Drupal\Core\Entity\RevisionableInterface $entity
* The default revision of the entity being converted.
* @param string $langcode
* The language of the revision translation to be loaded.
*
* @return \Drupal\Core\Entity\EntityInterface|\Drupal\Core\Entity\RevisionableInterface
* @return \Drupal\Core\Entity\RevisionableInterface
* The latest translation-affecting revision for the specified entity, or
* just the latest revision, if the specified entity is not translatable or
* does not have a matching translation yet.
......@@ -179,7 +179,6 @@ protected function getLatestTranslationAffectedRevision(RevisionableInterface $e
// revision. In this particular case the latest revision is always going
// to be the default revision, since pending revisions would not be
// supported.
/** @var \Drupal\Core\Entity\TranslatableRevisionableInterface $revision */
$revision = $revision_id ? $this->loadRevision($entity, $revision_id) : NULL;
if (!$revision || ($revision->wasDefaultRevision() && !$revision->isDefaultRevision())) {
$revision = NULL;
......@@ -201,18 +200,19 @@ protected function getLatestTranslationAffectedRevision(RevisionableInterface $e
/**
* Loads the specified entity revision.
*
* @param \Drupal\Core\Entity\EntityInterface|\Drupal\Core\Entity\RevisionableInterface $entity
* @param \Drupal\Core\Entity\RevisionableInterface $entity
* The default revision of the entity being converted.
* @param string $revision_id
* The identifier of the revision to be loaded.
*
* @return \Drupal\Core\Entity\EntityInterface|\Drupal\Core\Entity\RevisionableInterface
* @return \Drupal\Core\Entity\RevisionableInterface
* An entity revision object.
*/
protected function loadRevision(RevisionableInterface $entity, $revision_id) {
// We explicitly perform a loose equality check, since a revision ID may
// be returned as an integer or a string.
if ($entity->getLoadedRevisionId() != $revision_id) {
/** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */
$storage = $this->entityTypeManager->getStorage($entity->getEntityTypeId());
return $storage->loadRevision($revision_id);
}
......
......@@ -13,7 +13,7 @@ class ContentTranslationMetadataWrapper implements ContentTranslationMetadataWra
/**
* The wrapped entity translation.
*
* @var \Drupal\Core\Entity\EntityInterface|\Drupal\Core\Entity\FieldableEntityInterface|\Drupal\Core\TypedData\TranslatableInterface
* @var \Drupal\Core\Entity\FieldableEntityInterface|\Drupal\Core\TypedData\TranslatableInterface
*/
protected $translation;
......
......@@ -245,11 +245,10 @@ public function entityPredelete(EntityInterface $entity) {
* the new information. Otherwise, a new WorkspaceAssociation entity is created to
* store the passed-in entity's information.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* @param \Drupal\Core\Entity\RevisionableInterface $entity
* The entity to update or create from.
*/
protected function trackEntity(EntityInterface $entity) {
/** @var \Drupal\Core\Entity\RevisionableInterface|\Drupal\Core\Entity\EntityPublishedInterface $entity */
protected function trackEntity(RevisionableInterface $entity) {
// If the entity is not new, check if there's an existing
// WorkspaceAssociation entity for it.
$workspace_association_storage = $this->entityTypeManager->getStorage('workspace_association');
......
......@@ -582,7 +582,7 @@ protected function assertEntityLoad(array $expected_values, $entity_type_id) {
$published_key = $entity_keys['published'];
// Check \Drupal\Core\Entity\EntityStorageInterface::loadMultiple().
/** @var \Drupal\Core\Entity\EntityInterface[]|\Drupal\Core\Entity\RevisionableInterface[]|\Drupal\Core\Entity\EntityPublishedInterface[] $entities */
/** @var \Drupal\Core\Entity\RevisionableInterface[]|\Drupal\Core\Entity\EntityPublishedInterface[] $entities */
$entities = $this->entityTypeManager->getStorage($entity_type_id)->loadMultiple(array_column($expected_default_revisions, $id_key));
foreach ($expected_default_revisions as $expected_default_revision) {
$entity_id = $expected_default_revision[$id_key];
......@@ -593,7 +593,7 @@ protected function assertEntityLoad(array $expected_values, $entity_type_id) {
// Check \Drupal\Core\Entity\EntityStorageInterface::loadUnchanged().
foreach ($expected_default_revisions as $expected_default_revision) {
/** @var \Drupal\Core\Entity\EntityInterface|\Drupal\Core\Entity\RevisionableInterface|\Drupal\Core\Entity\EntityPublishedInterface $entity */
/** @var \Drupal\Core\Entity\RevisionableInterface|\Drupal\Core\Entity\EntityPublishedInterface $entity */
$entity = $this->entityTypeManager->getStorage($entity_type_id)->loadUnchanged($expected_default_revision[$id_key]);
$this->assertEquals($expected_default_revision[$revision_key], $entity->getRevisionId());
$this->assertEquals($expected_default_revision[$label_key], $entity->label());
......@@ -616,7 +616,7 @@ protected function assertEntityRevisionLoad(array $expected_values, $entity_type
$label_key = $entity_keys['label'];
$published_key = $entity_keys['published'];
/** @var \Drupal\Core\Entity\EntityInterface[]|\Drupal\Core\Entity\RevisionableInterface[]|\Drupal\Core\Entity\EntityPublishedInterface[] $entities */
/** @var \Drupal\Core\Entity\RevisionableInterface[]|\Drupal\Core\Entity\EntityPublishedInterface[] $entities */
$entities = $this->entityTypeManager->getStorage($entity_type_id)->loadMultipleRevisions(array_column($expected_values, $revision_key));
foreach ($expected_values as $expected_revision) {
$revision_id = $expected_revision[$revision_key];
......
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