Issue #3318888 by mondrake, Spokje, smustgrave, xjm, longwave: Fix migrate destination entity PHPStan L0 issues
parent
3324f140bb
commit
62d7c46774
|
@ -6,6 +6,7 @@ use Drupal\Component\Plugin\DependentPluginInterface;
|
||||||
use Drupal\Core\Entity\ContentEntityInterface;
|
use Drupal\Core\Entity\ContentEntityInterface;
|
||||||
use Drupal\Core\Entity\DependencyTrait;
|
use Drupal\Core\Entity\DependencyTrait;
|
||||||
use Drupal\Core\Entity\EntityFieldManagerInterface;
|
use Drupal\Core\Entity\EntityFieldManagerInterface;
|
||||||
|
use Drupal\Core\Entity\EntityInterface;
|
||||||
use Drupal\Core\Entity\EntityStorageInterface;
|
use Drupal\Core\Entity\EntityStorageInterface;
|
||||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||||
use Drupal\migrate\EntityFieldDefinitionTrait;
|
use Drupal\migrate\EntityFieldDefinitionTrait;
|
||||||
|
@ -181,6 +182,35 @@ abstract class Entity extends DestinationBase implements ContainerFactoryPluginI
|
||||||
return $entity;
|
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.
|
* Gets the entity ID of the row.
|
||||||
*
|
*
|
||||||
|
|
|
@ -193,6 +193,9 @@ class EntityConfigBase extends Entity {
|
||||||
* @param \Drupal\migrate\Row $row
|
* @param \Drupal\migrate\Row $row
|
||||||
* The row object to update from.
|
* The row object to update from.
|
||||||
*
|
*
|
||||||
|
* @return \Drupal\Core\Entity\EntityInterface
|
||||||
|
* An updated entity from row values.
|
||||||
|
*
|
||||||
* @throws \LogicException
|
* @throws \LogicException
|
||||||
* Thrown if the destination is for translations and either the "property"
|
* Thrown if the destination is for translations and either the "property"
|
||||||
* or "translation" property does not exist.
|
* or "translation" property does not exist.
|
||||||
|
@ -226,6 +229,8 @@ class EntityConfigBase extends Entity {
|
||||||
}
|
}
|
||||||
$this->setRollbackAction($row->getIdMap());
|
$this->setRollbackAction($row->getIdMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -266,15 +266,7 @@ class EntityContentBase extends Entity implements HighestIdInterface, MigrateVal
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates an entity with the new values from row.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @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) {
|
protected function updateEntity(EntityInterface $entity, Row $row) {
|
||||||
$empty_destinations = $row->getEmptyDestinationProperties();
|
$empty_destinations = $row->getEmptyDestinationProperties();
|
||||||
|
@ -325,10 +317,7 @@ class EntityContentBase extends Entity implements HighestIdInterface, MigrateVal
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populates as much of the stub row as possible.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @param \Drupal\migrate\Row $row
|
|
||||||
* The row of data.
|
|
||||||
*/
|
*/
|
||||||
protected function processStubRow(Row $row) {
|
protected function processStubRow(Row $row) {
|
||||||
$bundle_key = $this->getKey('bundle');
|
$bundle_key = $this->getKey('bundle');
|
||||||
|
|
|
@ -242,6 +242,14 @@ class EntityRevision extends RealEntityRevision {
|
||||||
* This method is from the parent and we aren't concerned with the inner
|
* 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
|
* workings of its implementation which would trickle into mock assertions. An
|
||||||
* empty implementation avoids this.
|
* 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) {
|
protected function updateEntity(EntityInterface $entity, Row $row) {
|
||||||
return $entity;
|
return $entity;
|
||||||
|
|
|
@ -90,12 +90,7 @@ class EntitySearchPage extends EntityConfigBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the entity with the contents of a row.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
|
||||||
* The search page entity.
|
|
||||||
* @param \Drupal\migrate\Row $row
|
|
||||||
* The row object to update from.
|
|
||||||
*/
|
*/
|
||||||
protected function updateEntity(EntityInterface $entity, Row $row) {
|
protected function updateEntity(EntityInterface $entity, Row $row) {
|
||||||
parent::updateEntity($entity, $row);
|
parent::updateEntity($entity, $row);
|
||||||
|
@ -105,6 +100,7 @@ class EntitySearchPage extends EntityConfigBase {
|
||||||
if ($plugin instanceof ConfigurableSearchPluginBase) {
|
if ($plugin instanceof ConfigurableSearchPluginBase) {
|
||||||
$plugin->setConfiguration($row->getDestinationProperty('configuration'));
|
$plugin->setConfiguration($row->getDestinationProperty('configuration'));
|
||||||
}
|
}
|
||||||
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1500,16 +1500,6 @@ parameters:
|
||||||
count: 1
|
count: 1
|
||||||
path: modules/migrate/src/Plugin/migrate/destination/Config.php
|
path: modules/migrate/src/Plugin/migrate/destination/Config.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Call to an undefined method Drupal\\\\migrate\\\\Plugin\\\\migrate\\\\destination\\\\Entity\\:\\:processStubRow\\(\\)\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: modules/migrate/src/Plugin/migrate/destination/Entity.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Call to an undefined method Drupal\\\\migrate\\\\Plugin\\\\migrate\\\\destination\\\\Entity\\:\\:updateEntity\\(\\)\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: modules/migrate/src/Plugin/migrate/destination/Entity.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Method Drupal\\\\migrate\\\\Plugin\\\\migrate\\\\destination\\\\Entity\\:\\:fields\\(\\) should return array but return statement is missing\\.$#"
|
message: "#^Method Drupal\\\\migrate\\\\Plugin\\\\migrate\\\\destination\\\\Entity\\:\\:fields\\(\\) should return array but return statement is missing\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
|
|
Loading…
Reference in New Issue