當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。