コード例 #1
0
ファイル: EntityConfigBase.php プロジェクト: ddrozdik/dmaps
 /**
  * Updates an entity with the contents of a row.
  *
  * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity to update.
  * @param \Drupal\migrate\Row $row
  *   The row object to update from.
  */
 protected function updateEntity(EntityInterface $entity, Row $row)
 {
     foreach ($row->getRawDestination() as $property => $value) {
         $this->updateEntityProperty($entity, explode(Row::PROPERTY_SEPARATOR, $property), $value);
     }
     $this->setRollbackAction($row->getIdMap());
 }
コード例 #2
0
ファイル: RowTest.php プロジェクト: aWEBoLabs/taxi
 /**
  * Tests getting/setting the ID Map.
  *
  * @covers ::setIdMap
  * @covers ::getIdMap
  */
 public function testGetSetIdMap()
 {
     $row = new Row($this->testValues, $this->testSourceIds);
     $test_id_map = array('original_hash' => '', 'hash' => '', 'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE);
     $row->setIdMap($test_id_map);
     $this->assertEquals($test_id_map, $row->getIdMap());
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function next()
 {
     $this->currentIds = NULL;
     $this->currentRow = NULL;
     $source_configuration = $this->migration->get('source');
     while ($this->getIterator()->valid()) {
         $row_data = $this->getIterator()->current() + $source_configuration;
         $this->getIterator()->next();
         $row = new Row($row_data, $this->migration->getSourcePlugin()->getIds(), $this->migration->get('destinationIds'));
         // Populate the source key for this row.
         $this->currentIds = $row->getSourceIdValues();
         // Pick up the existing map row, if any, unless getNextRow() did it.
         if (!$this->mapRowAdded && ($id_map = $this->idMap->getRowBySource($this->currentIds))) {
             $row->setIdMap($id_map);
         }
         // First, determine if this row should be passed to prepareRow(), or
         // skipped entirely. The rules are:
         // 1. If there's an explicit idlist, that's all we care about (ignore
         //    high waters and map rows).
         $prepared = FALSE;
         if (!empty($this->idList)) {
             if (in_array(reset($this->currentIds), $this->idList)) {
                 // In the list, fall through.
             } else {
                 // Not in the list, skip it.
                 continue;
             }
         } elseif (!$row->getIdMap()) {
             // Fall through
         } elseif ($row->needsUpdate()) {
             // Fall through.
         } elseif (!empty($this->highWaterProperty['field'])) {
             if ($this->trackChanges) {
                 if ($this->prepareRow($row) !== FALSE) {
                     if ($row->changed()) {
                         // This is a keeper
                         $this->currentRow = $row;
                         break;
                     } else {
                         // No change, skip it.
                         continue;
                     }
                 } else {
                     // prepareRow() told us to skip it.
                     continue;
                 }
             } else {
                 // No high water and not tracking changes, skip.
                 continue;
             }
         } elseif ($this->originalHighWater === '') {
             // Fall through
         } else {
             // Call prepareRow() here, in case the highWaterField needs preparation.
             if ($this->prepareRow($row) !== FALSE) {
                 if ($row->getSourceProperty($this->highWaterProperty['name']) > $this->originalHighWater) {
                     $this->currentRow = $row;
                     break;
                 } else {
                     // Skip.
                     continue;
                 }
             }
             $prepared = TRUE;
         }
         // Allow the Migration to prepare this row. prepareRow() can return
         // boolean FALSE to ignore this row.
         if (!$prepared) {
             if ($this->prepareRow($row) !== FALSE) {
                 // Finally, we've got a keeper.
                 $this->currentRow = $row;
                 break;
             } else {
                 $this->currentRow = NULL;
             }
         }
     }
     if ($this->currentRow) {
         $this->currentRow->freezeSource();
     } else {
         $this->currentIds = NULL;
     }
 }