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


PHP Migration::id方法代码示例

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


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

示例1: rollback

 /**
  * {@inheritdoc}
  */
 public function rollback()
 {
     // Only begin the rollback operation if the migration is currently idle.
     if ($this->migration->getStatus() !== MigrationInterface::STATUS_IDLE) {
         $this->message->display($this->t('Migration @id is busy with another operation: @status', ['@id' => $this->migration->id(), '@status' => $this->t($this->migration->getStatusLabel())]), 'error');
         return MigrationInterface::RESULT_FAILED;
     }
     // Announce that rollback is about to happen.
     $this->getEventDispatcher()->dispatch(MigrateEvents::PRE_ROLLBACK, new MigrateRollbackEvent($this->migration));
     // Optimistically assume things are going to work out; if not, $return will be
     // updated to some other status.
     $return = MigrationInterface::RESULT_COMPLETED;
     $this->migration->setStatus(MigrationInterface::STATUS_ROLLING_BACK);
     $id_map = $this->migration->getIdMap();
     $destination = $this->migration->getDestinationPlugin();
     // Loop through each row in the map, and try to roll it back.
     foreach ($id_map as $map_row) {
         $destination_key = $id_map->currentDestination();
         if ($destination_key) {
             $map_row = $id_map->getRowByDestination($destination_key);
             if ($map_row['rollback_action'] == MigrateIdMapInterface::ROLLBACK_DELETE) {
                 $this->getEventDispatcher()->dispatch(MigrateEvents::PRE_ROW_DELETE, new MigrateRowDeleteEvent($this->migration, $destination_key));
                 $destination->rollback($destination_key);
                 $this->getEventDispatcher()->dispatch(MigrateEvents::POST_ROW_DELETE, new MigrateRowDeleteEvent($this->migration, $destination_key));
             }
             // We're now done with this row, so remove it from the map.
             $id_map->deleteDestination($destination_key);
         }
         // Check for memory exhaustion.
         if (($return = $this->checkStatus()) != MigrationInterface::RESULT_COMPLETED) {
             break;
         }
         // If anyone has requested we stop, return the requested result.
         if ($this->migration->getStatus() == MigrationInterface::STATUS_STOPPING) {
             $return = $this->migration->getInterruptionResult();
             $this->migration->clearInterruptionResult();
             break;
         }
     }
     // If rollback completed successfully, reset the high water mark.
     if ($return == MigrationInterface::RESULT_COMPLETED) {
         $this->migration->saveHighWater(NULL);
     }
     // Notify modules that rollback attempt was complete.
     $this->getEventDispatcher()->dispatch(MigrateEvents::POST_ROLLBACK, new MigrateRollbackEvent($this->migration));
     $this->migration->setStatus(MigrationInterface::STATUS_IDLE);
     return $return;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:51,代码来源:MigrateExecutable.php

示例2: import

 /**
  * {@inheritdoc}
  */
 public function import()
 {
     $this->getEventDispatcher()->dispatch(MigrateEvents::PRE_IMPORT, new MigrateImportEvent($this->migration));
     // Knock off migration if the requirements haven't been met.
     try {
         $this->migration->checkRequirements();
     } catch (RequirementsException $e) {
         $this->message->display($this->t('Migration @id did not meet the requirements. @message @requirements', array('@id' => $this->migration->id(), '@message' => $e->getMessage(), '@requirements' => $e->getRequirementsString())), 'error');
         return MigrationInterface::RESULT_FAILED;
     }
     $return = MigrationInterface::RESULT_COMPLETED;
     $source = $this->getSource();
     $id_map = $this->migration->getIdMap();
     try {
         $source->rewind();
     } catch (\Exception $e) {
         $this->message->display($this->t('Migration failed with source plugin exception: !e', array('!e' => $e->getMessage())), 'error');
         return MigrationInterface::RESULT_FAILED;
     }
     $destination = $this->migration->getDestinationPlugin();
     while ($source->valid()) {
         $row = $source->current();
         if ($this->sourceIdValues = $row->getSourceIdValues()) {
             // Wipe old messages, and save any new messages.
             $id_map->delete($this->sourceIdValues, TRUE);
             $this->saveQueuedMessages();
         }
         try {
             $this->processRow($row);
             $save = TRUE;
         } catch (MigrateSkipRowException $e) {
             $id_map->saveIdMapping($row, array(), MigrateIdMapInterface::STATUS_IGNORED, $this->rollbackAction);
             $save = FALSE;
         }
         if ($save) {
             try {
                 $this->getEventDispatcher()->dispatch(MigrateEvents::PRE_ROW_SAVE, new MigratePreRowSaveEvent($this->migration, $row));
                 $destination_id_values = $destination->import($row, $id_map->lookupDestinationId($this->sourceIdValues));
                 $this->getEventDispatcher()->dispatch(MigrateEvents::POST_ROW_SAVE, new MigratePostRowSaveEvent($this->migration, $row, $destination_id_values));
                 if ($destination_id_values) {
                     // We do not save an idMap entry for config.
                     if ($destination_id_values !== TRUE) {
                         $id_map->saveIdMapping($row, $destination_id_values, $this->sourceRowStatus, $this->rollbackAction);
                     }
                 } else {
                     $id_map->saveIdMapping($row, array(), MigrateIdMapInterface::STATUS_FAILED, $this->rollbackAction);
                     if (!$id_map->messageCount()) {
                         $message = $this->t('New object was not saved, no error provided');
                         $this->saveMessage($message);
                         $this->message->display($message);
                     }
                 }
             } catch (MigrateException $e) {
                 $this->migration->getIdMap()->saveIdMapping($row, array(), $e->getStatus(), $this->rollbackAction);
                 $this->saveMessage($e->getMessage(), $e->getLevel());
                 $this->message->display($e->getMessage(), 'error');
             } catch (\Exception $e) {
                 $this->migration->getIdMap()->saveIdMapping($row, array(), MigrateIdMapInterface::STATUS_FAILED, $this->rollbackAction);
                 $this->handleException($e);
             }
         }
         if ($high_water_property = $this->migration->get('highWaterProperty')) {
             $this->migration->saveHighWater($row->getSourceProperty($high_water_property['name']));
         }
         // Reset row properties.
         unset($sourceValues, $destinationValues);
         $this->sourceRowStatus = MigrateIdMapInterface::STATUS_IMPORTED;
         if (($return = $this->checkStatus()) != MigrationInterface::RESULT_COMPLETED) {
             break;
         }
         try {
             $source->next();
         } catch (\Exception $e) {
             $this->message->display($this->t('Migration failed with source plugin exception: !e', array('!e' => $e->getMessage())), 'error');
             return MigrationInterface::RESULT_FAILED;
         }
     }
     $this->migration->setMigrationResult($return);
     $this->getEventDispatcher()->dispatch(MigrateEvents::POST_IMPORT, new MigrateImportEvent($this->migration));
     return $return;
 }
开发者ID:scratch,项目名称:gai,代码行数:84,代码来源:MigrateExecutable.php

示例3: executeMigration

 /**
  * Execute a single migration.
  *
  * @param \Drupal\migrate\Entity\Migration $migration
  *   The migration to run.
  *
  * @return \Drupal\migrate_tools\MigrateExecutable
  *   The migration executable.
  */
 protected function executeMigration($migration)
 {
     drush_log('Running ' . $migration->id(), 'ok');
     $executable = new MigrateExecutable($migration, $this->log);
     // drush_op() provides --simulate support.
     drush_op(array($executable, 'import'));
     return $executable;
 }
开发者ID:Wylbur,项目名称:eight,代码行数:17,代码来源:MigrateManifest.php


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