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


PHP Row::getSource方法代码示例

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


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

示例1: transform

 /**
  * {@inheritdoc}
  *
  * Generate the configuration rankings.
  */
 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
 {
     $return = array();
     foreach ($row->getSource() as $name => $rank) {
         if (substr($name, 0, 10) == 'node_rank_' && $rank) {
             $return[substr($name, 10)] = $rank;
         }
     }
     return $return;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:15,代码来源:SearchConfigurationRankings.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)
 {
     $src = $row->getSource();
     if (isset($src['category']) && !empty($src['category'])) {
         $cats = $src['category'];
         if (is_array($cats) && in_array('References', $cats)) {
             $value = 'project';
         }
     }
     return is_string($value) ? $value : NULL;
 }
开发者ID:digitaldonkey,项目名称:donkeymedia_migrate,代码行数:16,代码来源:PostNodeTypeProject.php

示例3: transform

 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
 {
     $value = strtotime($value);
     if (!$value || $value < 0) {
         $value = strtotime($row->getSource()['wp:post_date']);
     }
     if (!$value || $value < 0) {
         $value = time();
     }
     return $value;
 }
开发者ID:digitaldonkey,项目名称:wordpress_migrate,代码行数:11,代码来源:WordPressDateProcess.php

示例4: transform

 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
 {
     $wp_uri = $row->getSource()['wp:attachment_url'];
     $search = '/wp-content/uploads/';
     $uploads_dir_pos = strpos($wp_uri, $search);
     if ($uploads_dir_pos !== false) {
         return 'public://' . substr($wp_uri, $uploads_dir_pos + strlen($search));
     } else {
         // hmm.
         return 'public://' . basename($wp_uri);
     }
 }
开发者ID:digitaldonkey,项目名称:wordpress_migrate,代码行数:12,代码来源:WordPressAttachmentUriProcess.php

示例5: prepareRow

 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     $bundle = $row->getSourceProperty('type');
     // Pick up simple CCK fields.
     $cck_table = "content_type_{$bundle}";
     if ($this->tableExists($cck_table)) {
         $query = $this->select($cck_table, 'f')->condition('vid', $row->getSourceProperty('vid'));
         // The main column for the field should be rendered with the field name,
         // not the column name (e.g., field_foo rather than field_foo_value).
         $field_info = $this->getSourceFieldInfo($bundle);
         foreach ($field_info as $field_name => $info) {
             if (isset($info['columns']) && !$info['multiple'] && $info['db_storage']) {
                 $i = 0;
                 $data = FALSE;
                 foreach ($info['columns'] as $display_name => $column_name) {
                     if ($i++ == 0) {
                         $query->addField('f', $column_name, $field_name);
                     } else {
                         // The database API won't allow colons in column aliases, so we
                         // will accept the default alias, and fix up the field names later.
                         // Remember how to translate the field names.
                         if ($info['type'] == 'filefield' && (strpos($display_name, ':list') || strpos($display_name, ':description'))) {
                             if (!$data) {
                                 //$this->fileDataFields[] = $field_name . '_data';
                                 $query->addField('f', $field_name . '_data');
                                 $data = TRUE;
                             }
                         } else {
                             $query->addField('f', $column_name);
                         }
                     }
                 }
             }
         }
         if ($results = $query->execute()->fetchAssoc()) {
             $source = $row->getSource();
             // We diff the results because the extra will be all the field columns.
             $new_fields = array_diff($results, $source);
             foreach ($new_fields as $key => $value) {
                 $row->setSourceProperty($key, $value);
             }
         }
     }
     // Handle fields that have their own table.
     foreach ($this->getSourceFieldInfo($bundle) as $field_name => $field_info) {
         if ($field_info['multiple'] || !$field_info['db_storage']) {
             // Select the data.
             $table = "content_{$field_name}";
             $field_query = $this->select($table, 't')->condition('vid', $row->getSourceProperty('vid'));
             if ($field_info['multiple']) {
                 $field_query->addField('t', 'delta');
             }
             $data = FALSE;
             foreach ($field_info['columns'] as $display_name => $column_name) {
                 // The database API won't allow colons in column aliases, so we
                 // will accept the default alias, and fix up the field names later.
                 // Remember how to translate the field names.
                 if ($field_info['type'] == 'filefield' && (strpos($display_name, ':list') || strpos($display_name, ':description'))) {
                     if (!$data) {
                         //$this->fileDataFields[] = $field_name . '_data';
                         $field_query->addField('t', $field_name . '_data');
                         $data = TRUE;
                     }
                 } else {
                     $field_query->addField('t', $column_name);
                 }
             }
             if ($field_info['multiple']) {
                 foreach ($field_query->execute() as $field_row) {
                     foreach ($field_info['columns'] as $display_name => $column_name) {
                         list(, $column) = explode(':', $display_name);
                         $property_path = $field_name . Row::PROPERTY_SEPARATOR . $field_row['delta'] . Row::PROPERTY_SEPARATOR . $column;
                         $row->setSourceProperty($property_path, $field_row[$column_name]);
                     }
                 }
             } else {
                 if ($field_row = $field_query->execute()->fetchAssoc()) {
                     foreach ($field_info['columns'] as $display_name => $column_name) {
                         $row->setSourceProperty(str_replace(':', Row::PROPERTY_SEPARATOR, $display_name), $field_row[$column_name]);
                     }
                 }
             }
         }
     }
     parent::prepareRow($row);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:89,代码来源:CckFieldValues.php

示例6: testHashing

 /**
  * Tests hashing.
  */
 public function testHashing()
 {
     $row = new Row($this->testValues, $this->testSourceIds);
     $this->assertSame('', $row->getHash(), 'No hash at creation');
     $row->rehash();
     $this->assertSame($this->testHash, $row->getHash(), 'Correct hash.');
     $row->rehash();
     $this->assertSame($this->testHash, $row->getHash(), 'Correct hash even doing it twice.');
     // Set the map to needs update.
     $test_id_map = array('original_hash' => '', 'hash' => '', 'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE);
     $row->setIdMap($test_id_map);
     $this->assertTrue($row->needsUpdate());
     $row->rehash();
     $this->assertSame($this->testHash, $row->getHash(), 'Correct hash even if id_mpa have changed.');
     $row->setSourceProperty('title', 'new title');
     $row->rehash();
     $this->assertSame($this->testHashMod, $row->getHash(), 'Hash changed correctly.');
     // Check hash calculation algorithm.
     $hash = hash('sha256', serialize($row->getSource()));
     $this->assertSame($hash, $row->getHash());
     // Check length of generated hash used for mapping schema.
     $this->assertSame(64, strlen($row->getHash()));
     // Set the map to successfully imported.
     $test_id_map = array('original_hash' => '', 'hash' => '', 'source_row_status' => MigrateIdMapInterface::STATUS_IMPORTED);
     $row->setIdMap($test_id_map);
     $this->assertFalse($row->needsUpdate());
     // Set the same hash value and ensure it was not changed.
     $random = $this->randomMachineName();
     $test_id_map = array('original_hash' => $random, 'hash' => $random, 'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE);
     $row->setIdMap($test_id_map);
     $this->assertFalse($row->changed());
     // Set different has values to ensure it is marked as changed.
     $test_id_map = array('original_hash' => $this->randomMachineName(), 'hash' => $this->randomMachineName(), 'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE);
     $row->setIdMap($test_id_map);
     $this->assertTrue($row->changed());
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:39,代码来源:RowTest.php

示例7: import

 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     $source = $row->getSource();
     $this->tempStore->setWithExpire($source['uuid'], $source, $this->expire);
     return array($this->entityIdKey => $source[$this->entityIdKey]);
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:9,代码来源:TempStore.php

示例8: transformIngredients

 protected function transformIngredients($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
 {
     // WP uses newlines and transforms to <br>s at render time, but Drupal WYSIWYG adds <p>s on [enter].
     // Solution to get desired spacing of ingredients (1/line) is to make them css-styled <li>s.
     // Thus, locate each ingredient in WP text and transform to list item.
     if ($ingredients_ix = strpos($value, 'Ingredients:')) {
         $intro = substr($value, 0, $ingredients_ix);
         $rest_lines = explode("\n", substr($value, $ingredients_ix));
         /* Ingredients lists are charactarized by 4 or more adjacent lines of average length <= 50,
          * with at most one outlier of > 75, all terminated by a blank line.
          */
         $lengths = [];
         $three_before_had_content = false;
         $two_before_had_content = false;
         $last_had_content = false;
         $list_start_ix = false;
         for ($i = 1; $i <= 55 && $list_start_ix === false; $i++) {
             $lengths[$i] = strlen($rest_lines[$i]);
             if ($lengths[$i] > 75) {
                 $lengths[$i] = 25;
                 $outliers[$i] = 1;
             } else {
                 $outliers[$i] = 0;
             }
             if (trim($rest_lines[$i]) != '') {
                 if ($i >= 3) {
                     $avg = ($lengths[$i] + $lengths[$i - 1] + $lengths[$i - 2] + $lengths[$i - 3]) / 4;
                     $outliers_count = $outliers[$i] + $outliers[$i - 1] + $outliers[$i - 2] + $outliers[$i - 3];
                 } else {
                     $avg = 0;
                 }
                 if ($last_had_content && $two_before_had_content && $three_before_had_content && $outliers_count <= 1 && $avg > 0 && $avg <= 50) {
                     // we've found the start of the ingredients, two lines before here.
                     $list_start_ix = $i - 3;
                 }
                 $three_before_had_content = $two_before_had_content;
                 $two_before_had_content = $last_had_content;
                 $last_had_content = true;
             } else {
                 $three_before_had_content = $two_before_had_content;
                 $two_before_had_content = $last_had_content;
                 $last_had_content = false;
             }
         }
         if ($list_start_ix !== false) {
             // now find the end, first blank line
             $list_end_ix = false;
             for ($i = $list_start_ix + 1; $i < count($rest_lines) && $list_end_ix === false; $i++) {
                 if (trim($rest_lines[$i]) == '') {
                     $list_end_ix = $i - 1;
                 }
             }
             if ($list_end_ix === false) {
                 $list_end_ix = $i;
             }
             // add <ul></ul> around the list
             array_splice($rest_lines, $list_start_ix, 0, array('<ul>'));
             $list_start_ix++;
             $list_end_ix++;
             array_splice($rest_lines, $list_end_ix + 1, 0, array('</ul>'));
             // finally, wrap each ingredient in <li>
             for ($i = $list_start_ix; $i <= $list_end_ix; $i++) {
                 $rest_lines[$i] = '<li>' . $rest_lines[$i] . '</li>';
             }
             return $intro . implode("\n", $rest_lines);
         } else {
             trigger_error($row->getSource()['title'] . ": ingredients list not found under 'Ingredients:'", E_USER_WARNING);
             return $value;
         }
     } else {
         trigger_error($row->getSource()['title'] . ": has no ingredients", E_USER_WARNING);
         return $value;
     }
 }
开发者ID:digitaldonkey,项目名称:donkeymedia_migrate,代码行数:74,代码来源:PostBody.php


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