Commit 0df58b06 authored by xjm's avatar xjm

Issue #2275377 by martin107, mikeryan, chx, benjy, YesCT: Rename Row::stub to Row::isStub

parent 76fe710e
......@@ -279,9 +279,9 @@ protected function getProcessNormalized(array $process) {
/**
* {@inheritdoc}
*/
public function getDestinationPlugin($stub = FALSE) {
public function getDestinationPlugin($stub_being_requested = FALSE) {
if (!isset($this->destinationPlugin)) {
if ($stub && !empty($this->destination['no_stub'])) {
if ($stub_being_requested && !empty($this->destination['no_stub'])) {
throw new MigrateSkipRowException;
}
$this->destinationPlugin = \Drupal::service('plugin.manager.migrate.destination')->createInstance($this->destination['plugin'], $this->destination, $this);
......
......@@ -122,10 +122,13 @@ public function getProcessPlugins(array $process = NULL);
/**
* Returns the initialized destination plugin.
*
* @param bool $stub_being_requested
* TRUE to indicate that this destination will be asked to construct a stub.
*
* @return \Drupal\migrate\Plugin\MigrateDestinationInterface
* The destination plugin.
*/
public function getDestinationPlugin($stub = FALSE);
public function getDestinationPlugin($stub_being_requested = FALSE);
/**
* Returns the initialized id_map plugin.
......
......@@ -113,7 +113,7 @@ protected function getEntity(Row $row, array $old_destination_id_values) {
else {
$values = $row->getDestination();
// Stubs might not have the bundle specified.
if ($row->stub()) {
if ($row->isStub()) {
$values = $this->processStubValues($values);
}
$entity = $this->storage->create($values);
......
......@@ -77,11 +77,11 @@ public static function create(ContainerInterface $container, array $configuratio
* {@inheritdoc}
*/
public function import(Row $row, array $old_destination_id_values = array()) {
if ($row->stub() && ($state = $this->state->get('comment.maintain_entity_statistics', 0))) {
if ($row->isStub() && ($state = $this->state->get('comment.maintain_entity_statistics', 0))) {
$this->state->set('comment.maintain_entity_statistics', 0);
}
$return = parent::import($row, $old_destination_id_values);
if ($row->stub() && $state) {
if ($row->isStub() && $state) {
$this->state->set('comment.maintain_entity_statistics', $state);
}
return $return;
......
......@@ -28,7 +28,7 @@ class EntityConfigBase extends Entity {
* {@inheritdoc}
*/
public function import(Row $row, array $old_destination_id_values = array()) {
if ($row->stub()) {
if ($row->isStub()) {
throw new MigrateException('Config entities can not be stubbed.');
}
$ids = $this->getIds();
......
......@@ -20,7 +20,7 @@ class EntityTaxonomyTerm extends EntityContentBase {
* {@inheritdoc}
*/
protected function getEntity(Row $row, array $old_destination_id_values) {
if ($row->stub()) {
if ($row->isStub()) {
$row->setDestinationProperty('name', $this->t('Stub name for source tid:') . $row->getSourceProperty('tid'));
}
return parent::getEntity($row, $old_destination_id_values);
......
......@@ -125,8 +125,8 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
$values[$source_id] = $source_id_values[$migration->id()][$index];
}
$stub_row = new Row($values + $migration->get('source'), $source_ids);
$stub_row->stub(TRUE);
$stub_row = new Row($values + $migration->get('source'), $source_ids, TRUE);
// Do a normal migration with the stub row.
$migrate_executable->processRow($stub_row, $process);
$destination_ids = array();
......
......@@ -80,7 +80,7 @@ class Row {
*
* @var bool
*/
protected $stub = FALSE;
protected $isStub = FALSE;
/**
* Constructs a \Drupal\Migrate\Row object.
......@@ -90,13 +90,16 @@ class Row {
* @param array $source_ids
* An array containing the IDs of the source using the keys as the field
* names.
* @param bool $is_stub
* TRUE if the row being created is a stub.
*
* @throws \InvalidArgumentException
* Thrown when a source ID property does not exist.
*/
public function __construct(array $values, array $source_ids) {
public function __construct(array $values, array $source_ids, $is_stub = FALSE) {
$this->source = $values;
$this->sourceIds = $source_ids;
$this->isStub = $is_stub;
foreach (array_keys($source_ids) as $id) {
if (!$this->hasSourceProperty($id)) {
throw new \InvalidArgumentException("$id has no value");
......@@ -309,19 +312,12 @@ public function getHash() {
}
/**
* Flags and reports this row as a stub.
* Reports whether this row is a stub.
*
* @param bool|null $new_value
* TRUE when the row is a stub. Omit to determine whether the row is a
* stub.
*
* @return mixed
* @return bool
* The current stub value.
*/
public function stub($new_value = NULL) {
if (isset($new_value)) {
$this->stub = $new_value;
}
return $this->stub;
public function isStub() {
return $this->isStub;
}
}
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