當前位置: 首頁>>代碼示例>>PHP>>正文


PHP migrate\Row類代碼示例

本文整理匯總了PHP中Drupal\migrate\Row的典型用法代碼示例。如果您正苦於以下問題:PHP Row類的具體用法?PHP Row怎麽用?PHP Row使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Row類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: prepareRow

 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     $query = $this->select('upload', 'u')->fields('u', array('fid', 'description', 'list'))->condition('u.nid', $row->getSourceProperty('nid'))->orderBy('u.weight');
     $query->innerJoin('node', 'n', static::JOIN);
     $row->setSourceProperty('upload', $query->execute()->fetchAll());
     return parent::prepareRow($row);
 }
開發者ID:briefmedia-digital,項目名稱:drupal8,代碼行數:10,代碼來源:Upload.php

示例2: transform

 /**
  * Posts are either type recpie or restaurant_review.
  * Recpies contain <div class="recipe">, everything else is considered type
  * restaurant_review.
  */
 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
 {
     $return = array();
     $caption_tags = $this->getTags($value)['caption']['values'];
     if (is_array($caption_tags)) {
         foreach ($caption_tags as $image) {
             // Search for imported File:
             $q = db_select('migrate_map_donkeymedia_file', 'm')->fields('m', array('sourceid1', 'destid1'))->condition('m.sourceid1', $image['attachment'])->execute();
             $map = $q->fetchObject();
             if ($map) {
                 $dest = array('target_id' => $map->destid1, 'alt' => 'Sorry. No describing text available.', 'title' => 'No title');
                 // Alt Tag.
                 if (!empty($image['alt'])) {
                     $dest['alt'] = $image['alt'];
                 }
                 // Title.
                 if (!empty($image['caption'])) {
                     $dest['title'] = $image['caption'];
                 }
                 $return[] = $dest;
             } else {
                 echo 'Source Id: "' . $image['attachment'] . '" not Found in File Map table (migrate_map_donkeymedia_file)' . "\n";
                 throw new MigrateSkipProcessException();
             }
         }
     }
     if (!empty($return)) {
         $row->setDestinationProperty($destination_property, $return);
     }
 }
開發者ID:digitaldonkey,項目名稱:donkeymedia_migrate,代碼行數:35,代碼來源:AttachmentToFile.php

示例3: getFieldType

 /**
  * {@inheritdoc}
  */
 public function getFieldType(Row $row)
 {
     $widget_type = $row->getSourceProperty('widget_type');
     if ($widget_type == 'text_textfield') {
         $settings = $row->getSourceProperty('global_settings');
         $field_type = $settings['text_processing'] ? 'text' : 'string';
         if (empty($settings['max_length']) || $settings['max_length'] > 255) {
             $field_type .= '_long';
         }
         return $field_type;
     } else {
         switch ($widget_type) {
             case 'optionwidgets_buttons':
             case 'optionwidgets_select':
                 return 'list_string';
             case 'optionwidgets_onoff':
                 return 'boolean';
             case 'text_textarea':
                 return 'text_long';
             default:
                 return parent::getFieldType($row);
                 break;
         }
     }
 }
開發者ID:sgtsaughter,項目名稱:d8portfolio,代碼行數:28,代碼來源:TextField.php

示例4: prepareRow

 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     $uid = $row->getSourceProperty('uid');
     // field_real_name
     $result = $this->getDatabase()->query('
   SELECT
     fld.field_real_name_value
   FROM
     {dcf_field_data_field_real_name} fld
   WHERE
     fld.entity_id = :uid
 ', array(':uid' => $uid));
     foreach ($result as $record) {
         $row->setSourceProperty('field_real_name', $record->field_real_name_value);
     }
     // field_availability
     $result = $this->getDatabase()->query('
   SELECT
     fld.field_availability_value
   FROM
     {dcf_field_data_field_availability} fld
   WHERE
     fld.entity_id = :uid
 ', array(':uid' => $uid));
     foreach ($result as $record) {
         $row->setSourceProperty('field_availability', $record->field_availability_value);
     }
     return parent::prepareRow($row);
 }
開發者ID:atxajon,項目名稱:d8cafe,代碼行數:32,代碼來源:User.php

示例5: prepareRow

 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     $type = $row->getSourceProperty('type');
     $row->setSourceProperty('language_content_type', $this->variableGet('language_content_type_' . $type, NULL));
     $row->setSourceProperty('i18n_lock_node', $this->variableGet('i18n_lock_node_' . $type, 0));
     return parent::prepareRow($row);
 }
開發者ID:eigentor,項目名稱:tommiblog,代碼行數:10,代碼來源:LanguageContentSettings.php

示例6: prepareRow

 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     $data = unserialize($row->getSourceProperty('data'));
     $row->setSourceProperty('widget', $data['widget']);
     $row->setSourceProperty('widget_settings', $data['widget']['settings']);
     return parent::prepareRow($row);
 }
開發者ID:eigentor,項目名稱:tommiblog,代碼行數:10,代碼來源:FieldInstancePerFormDisplay.php

示例7: prepareRow

 public function prepareRow(Row $row)
 {
     if ($value = $row->getSourceProperty('beers')) {
         $row->setSourceProperty('beers', explode('|', $value));
     }
     return parent::prepareRow($row);
 }
開發者ID:Wylbur,項目名稱:eight,代碼行數:7,代碼來源:BeerUser.php

示例8: prepareRow

 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     $post_type = $row->getSourceProperty('post_type');
     $type = $post_type == 'page' ? 'page' : 'article';
     $row->setSourceProperty('type', $type);
     return parent::prepareRow($row);
 }
開發者ID:gl-prout,項目名稱:d8_migrate_wordpress,代碼行數:10,代碼來源:Posts.php

示例9: prepareRow

 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     if ($value = $row->getSourceProperty('value')) {
         $row->setSourceProperty('value', unserialize($value));
     }
     return parent::prepareRow($row);
 }
開發者ID:aWEBoLabs,項目名稱:taxi,代碼行數:10,代碼來源:VariableMultiRow.php

示例10: 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

示例11: prepareRow

 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     // Select all related tickets (rnid) to the current ticket (nid)
     $query = $this->select('support_reference', 'sr')->fields('sr', array('rnid'))->condition('sr.nid', $row->getSourceProperty('nid'));
     $row->setSourceProperty('rnid', $query->execute()->fetchCol());
     return parent::prepareRow($row);
 }
開發者ID:justincletus,項目名稱:webdrupalpro,代碼行數:10,代碼來源:SupportTicketReference.php

示例12: getEntityId

 /**
  * {@inheritdoc}
  */
 protected function getEntityId(Row $row)
 {
     $entity_type = $row->getDestinationProperty('entity_type');
     $bundle = $row->getDestinationProperty('bundle');
     $field_name = $row->getDestinationProperty('field_name');
     return "{$entity_type}.{$bundle}.{$field_name}";
 }
開發者ID:aWEBoLabs,項目名稱:taxi,代碼行數:10,代碼來源:EntityBaseFieldOverride.php

示例13: import

 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     $source = $this->configuration['source_base_path'] . $row->getSourceProperty($this->configuration['source_path_property']);
     $destination = $row->getDestinationProperty($this->configuration['destination_path_property']);
     $replace = FILE_EXISTS_REPLACE;
     if (!empty($this->configuration['rename'])) {
         $entity_id = $row->getDestinationProperty($this->getKey('id'));
         if (!empty($entity_id) && ($entity = $this->storage->load($entity_id))) {
             $replace = FILE_EXISTS_RENAME;
         }
     }
     $dirname = drupal_dirname($destination);
     if (!file_prepare_directory($dirname, FILE_CREATE_DIRECTORY)) {
         throw new MigrateException(t('Could not create directory %dirname', array('%dirname' => $dirname)));
     }
     if ($this->configuration['move']) {
         $copied = file_unmanaged_move($source, $destination, $replace);
     } else {
         // Determine whether we can perform this operation based on overwrite rules.
         $original_destination = $destination;
         $destination = file_destination($destination, $replace);
         if ($destination === FALSE) {
             throw new MigrateException(t('File %file could not be copied because a file by that name already exists in the destination directory (%destination)', array('%file' => $source, '%destination' => $original_destination)));
         }
         $source = $this->urlencode($source);
         $copied = copy($source, $destination);
     }
     if ($copied) {
         return parent::import($row, $old_destination_id_values);
     } else {
         throw new MigrateException(t('File %source could not be copied to %destination.', array('%source' => $source, '%destination' => $destination)));
     }
 }
開發者ID:davidsoloman,項目名稱:drupalconsole.com,代碼行數:36,代碼來源:EntityFile.php

示例14: 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

示例15: 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


注:本文中的Drupal\migrate\Row類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。