当前位置: 首页>>代码示例>>PHP>>正文


PHP Row::needsUpdate方法代码示例

本文整理汇总了PHP中Drupal\migrate\Row::needsUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP Row::needsUpdate方法的具体用法?PHP Row::needsUpdate怎么用?PHP Row::needsUpdate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\migrate\Row的用法示例。


在下文中一共展示了Row::needsUpdate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testHashing

 /**
  * Tests hashing.
  */
 public function testHashing()
 {
     $row = new Row($this->testValues, $this->testSourceIds);
     $this->assertSame('', $row->getHash(), 'No hash at creation');
     $row->rehash();
     $this->assertSame($this->testHash, $row->getHash(), 'Correct hash.');
     $row->rehash();
     $this->assertSame($this->testHash, $row->getHash(), 'Correct hash even doing it twice.');
     // Set the map to needs update.
     $test_id_map = array('original_hash' => '', 'hash' => '', 'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE);
     $row->setIdMap($test_id_map);
     $this->assertTrue($row->needsUpdate());
     $row->rehash();
     $this->assertSame($this->testHash, $row->getHash(), 'Correct hash even if id_mpa have changed.');
     $row->setSourceProperty('title', 'new title');
     $row->rehash();
     $this->assertSame($this->testHashMod, $row->getHash(), 'Hash changed correctly.');
     // Check hash calculation algorithm.
     $hash = hash('sha256', serialize($row->getSource()));
     $this->assertSame($hash, $row->getHash());
     // Check length of generated hash used for mapping schema.
     $this->assertSame(64, strlen($row->getHash()));
     // Set the map to successfully imported.
     $test_id_map = array('original_hash' => '', 'hash' => '', 'source_row_status' => MigrateIdMapInterface::STATUS_IMPORTED);
     $row->setIdMap($test_id_map);
     $this->assertFalse($row->needsUpdate());
     // Set the same hash value and ensure it was not changed.
     $random = $this->randomMachineName();
     $test_id_map = array('original_hash' => $random, 'hash' => $random, 'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE);
     $row->setIdMap($test_id_map);
     $this->assertFalse($row->changed());
     // Set different has values to ensure it is marked as changed.
     $test_id_map = array('original_hash' => $this->randomMachineName(), 'hash' => $this->randomMachineName(), 'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE);
     $row->setIdMap($test_id_map);
     $this->assertTrue($row->changed());
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:39,代码来源:RowTest.php

示例2: next

 /**
  * {@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;
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:86,代码来源:Source.php


注:本文中的Drupal\migrate\Row::needsUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。