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


PHP Row::isStub方法代码示例

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


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

示例1: import

 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     if ($row->isStub()) {
         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:HakS,项目名称:drupal8_training,代码行数:31,代码来源:EntityConfigBase.php

示例2: transform

 /**
  * {@inheritdoc}
  */
 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
 {
     // If we're stubbing a file entity, return a URI of NULL so it will get
     // stubbed by the general process.
     if ($row->isStub()) {
         return NULL;
     }
     list($source, $destination) = $value;
     // Ensure the source file exists, if it's a local URI or path.
     if ($this->isLocalUri($source) && !file_exists($source)) {
         throw new MigrateException("File '{$source}' does not exist");
     }
     // If the start and end file is exactly the same, there is nothing to do.
     if ($this->isLocationUnchanged($source, $destination)) {
         return $destination;
     }
     $replace = $this->getOverwriteMode();
     // We attempt the copy/move first to avoid calling file_prepare_directory()
     // any more than absolutely necessary.
     $final_destination = $this->writeFile($source, $destination, $replace);
     if ($final_destination) {
         return $final_destination;
     }
     // If writeFile didn't work, make sure there's a writable directory in
     // place.
     $dir = $this->getDirectory($destination);
     if (!file_prepare_directory($dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
         throw new MigrateException("Could not create or write to directory '{$dir}'");
     }
     $final_destination = $this->writeFile($source, $destination, $replace);
     if ($final_destination) {
         return $final_destination;
     }
     throw new MigrateException("File {$source} could not be copied to {$destination}");
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:38,代码来源:FileCopy.php

示例3: getEntity

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

示例4: import

 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     // For stub rows, there is no real file to deal with, let the stubbing
     // process create the stub entity.
     if ($row->isStub()) {
         return parent::import($row, $old_destination_id_values);
     }
     $file = $row->getSourceProperty($this->configuration['source_path_property']);
     $destination = $row->getDestinationProperty($this->configuration['destination_path_property']);
     $source = $this->configuration['source_base_path'] . $file;
     // Ensure the source file exists, if it's a local URI or path.
     if ($this->isLocalUri($source) && !file_exists($source)) {
         throw new MigrateException("File '{$source}' does not exist.");
     }
     // If the start and end file is exactly the same, there is nothing to do.
     if ($this->isLocationUnchanged($source, $destination)) {
         return parent::import($row, $old_destination_id_values);
     }
     $replace = $this->getOverwriteMode($row);
     $success = $this->writeFile($source, $destination, $replace);
     if (!$success) {
         $dir = $this->getDirectory($destination);
         if (file_prepare_directory($dir, FILE_CREATE_DIRECTORY)) {
             $success = $this->writeFile($source, $destination, $replace);
         } else {
             throw new MigrateException("Could not create directory '{$dir}'");
         }
     }
     if ($success) {
         return parent::import($row, $old_destination_id_values);
     } else {
         throw new MigrateException("File {$source} could not be copied to {$destination}.");
     }
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:37,代码来源:EntityFile.php

示例5: transform

 /**
  * {@inheritdoc}
  */
 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
 {
     // If we're stubbing a file entity, return a uri of NULL so it will get
     // stubbed by the general process.
     if ($row->isStub()) {
         return NULL;
     }
     list($source, $destination) = $value;
     // Modify the destination filename if necessary.
     $replace = !empty($this->configuration['rename']) ? FILE_EXISTS_RENAME : FILE_EXISTS_REPLACE;
     $final_destination = file_destination($destination, $replace);
     // Try opening the file first, to avoid calling file_prepare_directory()
     // unnecessarily. We're suppressing fopen() errors because we want to try
     // to prepare the directory before we give up and fail.
     $destination_stream = @fopen($final_destination, 'w');
     if (!$destination_stream) {
         // If fopen didn't work, make sure there's a writable directory in place.
         $dir = $this->fileSystem->dirname($final_destination);
         if (!file_prepare_directory($dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
             throw new MigrateException("Could not create or write to directory '{$dir}'");
         }
         // Let's try that fopen again.
         $destination_stream = @fopen($final_destination, 'w');
         if (!$destination_stream) {
             throw new MigrateException("Could not write to file '{$final_destination}'");
         }
     }
     // Stream the request body directly to the final destination stream.
     $this->configuration['guzzle_options']['sink'] = $destination_stream;
     // Make the request. Guzzle throws an exception for anything other than 200.
     $this->httpClient->get($source, $this->configuration['guzzle_options']);
     return $final_destination;
 }
开发者ID:Greg-Boggs,项目名称:electric-dev,代码行数:36,代码来源:Download.php

示例6: import

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

示例7: transform

 /**
  * {@inheritdoc}
  */
 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
 {
     // If we're stubbing a file entity, return a uri of NULL so it will get
     // stubbed by the general process.
     if ($row->isStub()) {
         return NULL;
     }
     list($filepath, $file_directory_path, $temp_directory_path, $is_public) = $value;
     // Specific handling using $temp_directory_path for temporary files.
     if (substr($filepath, 0, strlen($temp_directory_path)) === $temp_directory_path) {
         $uri = preg_replace('/^' . preg_quote($temp_directory_path, '/') . '/', '', $filepath);
         return 'temporary://' . ltrim($uri, '/');
     }
     // Strip the files path from the uri instead of using basename
     // so any additional folders in the path are preserved.
     $uri = preg_replace('/^' . preg_quote($file_directory_path, '/') . '/', '', $filepath);
     return ($is_public ? 'public' : 'private') . '://' . ltrim($uri, '/');
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:21,代码来源:FileUri.php

示例8: getEntity

 /**
  * {@inheritdoc}
  */
 protected function getEntity(Row $row, array $old_destination_id_values)
 {
     // For stub rows, there is no real file to deal with, let the stubbing
     // process take its default path.
     if ($row->isStub()) {
         return parent::getEntity($row, $old_destination_id_values);
     }
     // By default the entity key (fid) would be used, but we want to make sure
     // we're loading the matching URI.
     $destination = $row->getDestinationProperty('uri');
     if (empty($destination)) {
         throw new MigrateException('Destination property uri not provided');
     }
     $entity = $this->storage->loadByProperties(['uri' => $destination]);
     if ($entity) {
         return reset($entity);
     } else {
         return parent::getEntity($row, $old_destination_id_values);
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:23,代码来源:EntityFile.php


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