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


PHP Row::stub方法代码示例

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


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

示例1: getEntity

 /**
  * {@inheritdoc}
  */
 protected function getEntity(Row $row, array $old_destination_id_values)
 {
     if ($row->stub()) {
         $row->setDestinationProperty('name', $this->t('Stub name for source tid:') . $row->getSourceProperty('tid'));
     }
     return parent::getEntity($row, $old_destination_id_values);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:10,代码来源:EntityTaxonomyTerm.php

示例2: import

 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     if ($row->stub()) {
         throw new MigrateException('Config entities can not be stubbed.');
     }
     $ids = $this->getIds();
     $id_key = $this->getKey('id');
     if (count($ids) > 1) {
         // Ids is keyed by the key name so grab the keys.
         $id_keys = array_keys($ids);
         if (!$row->getDestinationProperty($id_key)) {
             // Set the id into the destination in for form "val1.val2.val3".
             $row->setDestinationProperty($id_key, $this->generateId($row, $id_keys));
         }
     }
     $entity = $this->getEntity($row, $old_destination_id_values);
     $entity->save();
     if (count($ids) > 1) {
         // This can only be a config entity, content entities have their id key
         // and that's it.
         $return = array();
         foreach ($id_keys as $id_key) {
             $return[] = $entity->get($id_key);
         }
         return $return;
     }
     return array($entity->id());
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:31,代码来源:EntityConfigBase.php

示例3: import

 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     if ($row->stub() && ($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) {
         $this->state->set('comment.maintain_entity_statistics', $state);
     }
     return $return;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:14,代码来源:EntityComment.php

示例4: transform

 /**
  * {@inheritdoc}
  */
 public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property)
 {
     $migration_ids = $this->configuration['migration'];
     if (!is_array($migration_ids)) {
         $migration_ids = array($migration_ids);
     }
     $scalar = FALSE;
     if (!is_array($value)) {
         $scalar = TRUE;
         $value = array($value);
     }
     $self = FALSE;
     /** @var \Drupal\migrate\Entity\MigrationInterface[] $migrations */
     $migrations = $this->migrationStorage->loadMultiple($migration_ids);
     $destination_ids = NULL;
     $source_id_values = array();
     foreach ($migrations as $migration_id => $migration) {
         if ($migration_id == $this->migration->id()) {
             $self = TRUE;
         }
         if (isset($this->configuration['source_ids'][$migration_id])) {
             $configuration = array('source' => $this->configuration['source_ids'][$migration_id]);
             $source_id_values[$migration_id] = $this->processPluginManager->createInstance('get', $configuration, $this->migration)->transform(NULL, $migrate_executable, $row, $destination_property);
         } else {
             $source_id_values[$migration_id] = $value;
         }
         // Break out of the loop as soon as a destination ID is found.
         if ($destination_ids = $migration->getIdMap()->lookupDestinationID($source_id_values[$migration_id])) {
             break;
         }
     }
     if (!$destination_ids && ($self && empty($this->configuration['no_stub']) || isset($this->configuration['stub_id']) || count($migrations) == 1)) {
         // If the lookup didn't succeed, figure out which migration will do the
         // stubbing.
         if ($self) {
             $migration = $this->migration;
         } elseif (isset($this->configuration['stub_id'])) {
             $migration = $migrations[$this->configuration['stub_id']];
         } else {
             $migration = reset($migrations);
         }
         $destination_plugin = $migration->getDestinationPlugin();
         // Only keep the process necessary to produce the destination ID.
         $process = array_intersect_key($migration->get('process'), $destination_plugin->getIds());
         // We already have the source id values but need to key them for the Row
         // constructor.
         $source_ids = $migration->getSourcePlugin()->getIds();
         $values = array();
         foreach (array_keys($source_ids) as $index => $source_id) {
             $values[$source_id] = $source_id_values[$migration->id()][$index];
         }
         $stub_row = new Row($values, $source_ids);
         $stub_row->stub(TRUE);
         // Do a normal migration with the stub row.
         $migrate_executable->processRow($stub_row, $process);
         $destination_ids = array();
         try {
             $destination_ids = $destination_plugin->import($stub_row);
         } catch (MigrateException $e) {
         }
     }
     if ($destination_ids) {
         if ($scalar) {
             if (count($destination_ids) == 1) {
                 return reset($destination_ids);
             }
         } else {
             return $destination_ids;
         }
     }
     throw new MigrateSkipRowException();
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:75,代码来源:Migration.php


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