Verified Commit 62d7c467 authored by Dave Long's avatar Dave Long
Browse files

Issue #3318888 by mondrake, Spokje, smustgrave, xjm, longwave: Fix migrate...

Issue #3318888 by mondrake, Spokje, smustgrave, xjm, longwave: Fix migrate destination entity PHPStan L0 issues
parent 3324f140
Loading
Loading
Loading
Loading
+30 −0
Changes for core/modules/migrate/src/Plugin/migrate/destination/Entity.php: 30 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\DependencyTrait;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\EntityFieldDefinitionTrait;
@@ -181,6 +182,35 @@ protected function getEntity(Row $row, array $old_destination_id_values) {
    return $entity;
  }

  /**
   * Updates an entity with the new values from row.
   *
   * This method should be implemented in extending classes.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity to update.
   * @param \Drupal\migrate\Row $row
   *   The row object to update from.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   An updated entity from row values.
   *
   * @throws \LogicException
   *   Thrown for config entities, if the destination is for translations and
   *   either the "property" or "translation" property does not exist.
   */
  abstract protected function updateEntity(EntityInterface $entity, Row $row);

  /**
   * Populates as much of the stub row as possible.
   *
   * This method can be implemented in extending classes when needed.
   *
   * @param \Drupal\migrate\Row $row
   *   The row of data.
   */
  protected function processStubRow(Row $row) {}

  /**
   * Gets the entity ID of the row.
   *
+5 −0
Changes for core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -193,6 +193,9 @@ public function getIds() {
   * @param \Drupal\migrate\Row $row
   *   The row object to update from.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   An updated entity from row values.
   *
   * @throws \LogicException
   *   Thrown if the destination is for translations and either the "property"
   *   or "translation" property does not exist.
@@ -226,6 +229,8 @@ protected function updateEntity(EntityInterface $entity, Row $row) {
      }
      $this->setRollbackAction($row->getIdMap());
    }

    return $entity;
  }

  /**
+2 −13
Changes for core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php: 2 added lines, 13 removed lines.
Original line number Diff line number Diff line
@@ -266,15 +266,7 @@ public function getIds() {
  }

  /**
   * Updates an entity with the new values from row.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity to update.
   * @param \Drupal\migrate\Row $row
   *   The row object to update from.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   An updated entity from row values.
   * {@inheritdoc}
   */
  protected function updateEntity(EntityInterface $entity, Row $row) {
    $empty_destinations = $row->getEmptyDestinationProperties();
@@ -325,10 +317,7 @@ protected function updateEntity(EntityInterface $entity, Row $row) {
  }

  /**
   * Populates as much of the stub row as possible.
   *
   * @param \Drupal\migrate\Row $row
   *   The row of data.
   * {@inheritdoc}
   */
  protected function processStubRow(Row $row) {
    $bundle_key = $this->getKey('bundle');
+8 −0
Changes for core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -242,6 +242,14 @@ public function save(ContentEntityInterface $entity, array $old_destination_id_v
   * This method is from the parent and we aren't concerned with the inner
   * workings of its implementation which would trickle into mock assertions. An
   * empty implementation avoids this.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity to update.
   * @param \Drupal\migrate\Row $row
   *   The row object to update from.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   An updated entity from row values.
   */
  protected function updateEntity(EntityInterface $entity, Row $row) {
    return $entity;
+2 −6
Changes for core/modules/search/src/Plugin/migrate/destination/EntitySearchPage.php: 2 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -90,12 +90,7 @@ public function import(Row $row, array $old_destination_id_values = []) {
  }

  /**
   * Updates the entity with the contents of a row.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The search page entity.
   * @param \Drupal\migrate\Row $row
   *   The row object to update from.
   * {@inheritdoc}
   */
  protected function updateEntity(EntityInterface $entity, Row $row) {
    parent::updateEntity($entity, $row);
@@ -105,6 +100,7 @@ protected function updateEntity(EntityInterface $entity, Row $row) {
    if ($plugin instanceof ConfigurableSearchPluginBase) {
      $plugin->setConfiguration($row->getDestinationProperty('configuration'));
    }
    return $entity;
  }

}
Loading