本文整理汇总了PHP中Drupal\migrate\Row::getSourceProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP Row::getSourceProperty方法的具体用法?PHP Row::getSourceProperty怎么用?PHP Row::getSourceProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\migrate\Row
的用法示例。
在下文中一共展示了Row::getSourceProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareRow
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row)
{
$row->setSourceProperty('options', unserialize($row->getSourceProperty('options')));
$row->setSourceProperty('enabled', !$row->getSourceProperty('hidden'));
$row->setSourceProperty('description', Unicode::truncate($row->getSourceProperty('options/attributes/title'), 255));
return parent::prepareRow($row);
}
示例2: prepareRow
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row)
{
$roles = $this->select('users_roles', 'ur')->fields('ur', ['rid'])->condition('ur.uid', $row->getSourceProperty('uid'))->execute()->fetchCol();
$row->setSourceProperty('roles', $roles);
$row->setSourceProperty('data', unserialize($row->getSourceProperty('data')));
// Get Field API field values.
foreach (array_keys($this->getFields('user')) as $field) {
$row->setSourceProperty($field, $this->getFieldValues('user', $field, $row->getSourceProperty('uid')));
}
// Get profile field values. This code is lifted directly from the D6
// ProfileFieldValues plugin.
if ($this->getDatabase()->schema()->tableExists('profile_value')) {
$query = $this->select('profile_value', 'pv')->fields('pv', array('fid', 'value'));
$query->leftJoin('profile_field', 'pf', 'pf.fid=pv.fid');
$query->fields('pf', array('name', 'type'));
$query->condition('uid', $row->getSourceProperty('uid'));
$results = $query->execute();
foreach ($results as $profile_value) {
if ($profile_value['type'] == 'date') {
$date = unserialize($profile_value['value']);
$date = date('Y-m-d', mktime(0, 0, 0, $date['month'], $date['day'], $date['year']));
$row->setSourceProperty($profile_value['name'], array('value' => $date));
} elseif ($profile_value['type'] == 'list') {
// Explode by newline and comma.
$row->setSourceProperty($profile_value['name'], preg_split("/[\r\n,]+/", $profile_value['value']));
} else {
$row->setSourceProperty($profile_value['name'], array($profile_value['value']));
}
}
}
return parent::prepareRow($row);
}
示例3: prepareRow
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row)
{
$row->setSourceProperty('teaser_length', $this->teaserLength);
$row->setSourceProperty('node_preview', $this->nodePreview);
$type = $row->getSourceProperty('type');
$source_options = $this->variableGet('node_options_' . $type, array('promote', 'sticky'));
$options = array();
foreach (array('promote', 'sticky', 'status', 'revision') as $item) {
$options[$item] = in_array($item, $source_options);
}
$row->setSourceProperty('options', $options);
// Don't create a body field until we prove that this node type has one.
$row->setSourceProperty('create_body', FALSE);
if ($this->moduleExists('field')) {
// Find body field for this node type.
$body = $this->select('field_config_instance', 'fci')->fields('fci', array('data'))->condition('entity_type', 'node')->condition('bundle', $row->getSourceProperty('type'))->condition('field_name', 'body')->execute()->fetchAssoc();
if ($body) {
$row->setSourceProperty('create_body', TRUE);
$body['data'] = unserialize($body['data']);
$row->setSourceProperty('body_label', $body['data']['label']);
}
}
$row->setSourceProperty('display_submitted', $this->variableGet('node_submitted_' . $type, TRUE));
return parent::prepareRow($row);
}
示例4: prepareRow
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row)
{
$filters = array();
$roles = $row->getSourceProperty('roles');
$row->setSourceProperty('roles', array_values(array_filter(explode(',', $roles))));
$format = $row->getSourceProperty('format');
// Find filters for this row.
$results = $this->select('filters', 'f')->fields('f', array('module', 'delta', 'weight'))->condition('format', $format)->execute();
foreach ($results as $raw_filter) {
$module = $raw_filter['module'];
$delta = $raw_filter['delta'];
$filter = array('module' => $module, 'delta' => $delta, 'weight' => $raw_filter['weight'], 'settings' => array());
// Load the filter settings for the filter module, modules can use
// hook_migration_d6_filter_formats_prepare_row() to add theirs.
if ($raw_filter['module'] == 'filter') {
if (!$delta) {
if ($setting = $this->variableGet("allowed_html_{$format}", NULL)) {
$filter['settings']['allowed_html'] = $setting;
}
if ($setting = $this->variableGet("filter_html_help_{$format}", NULL)) {
$filter['settings']['filter_html_help'] = $setting;
}
if ($setting = $this->variableGet("filter_html_nofollow_{$format}", NULL)) {
$filter['settings']['filter_html_nofollow'] = $setting;
}
} elseif ($delta == 2 && ($setting = $this->variableGet("filter_url_length_{$format}", NULL))) {
$filter['settings']['filter_url_length'] = $setting;
}
}
$filters[] = $filter;
}
$row->setSourceProperty('filters', $filters);
return parent::prepareRow($row);
}
示例5: 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;
}
}
}
示例6: prepareRow
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
// User roles.
$roles = $this->select('users_roles', 'ur')
->fields('ur', array('rid'))
->condition('ur.uid', $row->getSourceProperty('uid'))
->execute()
->fetchCol();
$row->setSourceProperty('roles', $roles);
// We are adding here the Event contributed module column.
// @see https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7002/7
if ($row->hasSourceProperty('timezone_id') && $row->getSourceProperty('timezone_id')) {
if ($this->getDatabase()->schema()->tableExists('event_timezones')) {
$event_timezone = $this->select('event_timezones', 'e')
->fields('e', array('name'))
->condition('e.timezone', $row->getSourceProperty('timezone_id'))
->execute()
->fetchField();
if ($event_timezone) {
$row->setSourceProperty('event_timezone', $event_timezone);
}
}
}
// Unserialize Data.
$row->setSourceProperty('data', unserialize($row->getSourceProperty('data')));
return parent::prepareRow($row);
}
示例7: prepareRow
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row)
{
// Find node types for this row.
$node_types = $this->select('vocabulary_node_types', 'nt')->fields('nt', array('type', 'vid'))->condition('vid', $row->getSourceProperty('vid'))->execute()->fetchCol();
$row->setSourceProperty('node_types', $node_types);
$row->setSourceProperty('cardinality', $row->getSourceProperty('tags') == 1 || $row->getSourceProperty('multiple') == 1 ? FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED : 1);
return parent::prepareRow($row);
}
示例8: transform
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
{
$value = $row->getSourceProperty('settings');
if ($row->getSourceProperty('type') == 'image' && !is_array($value['default_image'])) {
$value['default_image'] = array('uuid' => '');
}
return $value;
}
示例9: prepareRow
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row)
{
// Get Field API field values.
foreach (array_keys($this->getFields('node', $row->getSourceProperty('type'))) as $field) {
$nid = $row->getSourceProperty('nid');
$vid = $row->getSourceProperty('vid');
$row->setSourceProperty($field, $this->getFieldValues('node', $field, $nid, $vid));
}
return parent::prepareRow($row);
}
示例10: prepareRow
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row, $keep = TRUE)
{
// Unserialize data.
$global_settings = unserialize($row->getSourceProperty('global_settings'));
$widget_settings = unserialize($row->getSourceProperty('widget_settings'));
$db_columns = unserialize($row->getSourceProperty('db_columns'));
$row->setSourceProperty('global_settings', $global_settings);
$row->setSourceProperty('widget_settings', $widget_settings);
$row->setSourceProperty('db_columns', $db_columns);
return parent::prepareRow($row);
}
示例11: prepareRow
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row)
{
$cid = $row->getSourceProperty('cid');
$node_type = $row->getSourceProperty('node_type');
$comment_type = 'comment_node_' . $node_type;
$row->setSourceProperty('comment_type', 'comment_node_' . $node_type);
foreach (array_keys($this->getFields('comment', $comment_type)) as $field) {
$row->setSourceProperty($field, $this->getFieldValues('comment', $field, $cid));
}
return parent::prepareRow($row);
}
示例12: prepareRow
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row)
{
// Unserialize data.
$widget_settings = unserialize($row->getSourceProperty('widget_settings'));
$display_settings = unserialize($row->getSourceProperty('display_settings'));
$global_settings = unserialize($row->getSourceProperty('global_settings'));
$row->setSourceProperty('widget_settings', $widget_settings);
$row->setSourceProperty('display_settings', $display_settings);
$row->setSourceProperty('global_settings', $global_settings);
return parent::prepareRow($row);
}
示例13: prepareRow
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row)
{
$aid = $row->getSourceProperty('aid');
if (is_numeric($aid)) {
if ($this->getModuleSchemaVersion('system') >= 7000) {
$label = $row->getSourceProperty('label');
} else {
$label = $row->getSourceProperty('description');
}
$row->setSourceProperty('aid', $label);
}
}
示例14: transform
/**
* {@inheritdoc}
*
* Migrate filter format serial to string id in permission name.
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
{
$rid = $row->getSourceProperty('rid');
if ($formats = $row->getSourceProperty("filter_permissions:{$rid}")) {
foreach ($formats as $format) {
$new_id = $this->migrationPlugin->transform($format, $migrate_executable, $row, $destination_property);
if ($new_id) {
$value[] = 'use text format ' . $new_id;
}
}
}
return $value;
}
示例15: prepareRow
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row)
{
/**
* Let's go get the subTeam taxonomy tid for each product
*/
$start = $row->getSourceProperty('salestart');
if (!is_null($start)) {
// drupal_set_message('start:' . $start) ;
$timestamp = strtotime($start);
$start = date("Y-m-d\\TH:i:s", $timestamp);
// drupal_set_message('reformatted start: ' . $start);
$row->setSourceProperty('salestart', $start);
}
$end = $row->getSourceProperty('saleend');
if (!is_null($end)) {
// drupal_set_message('end:' . $end);
$timestamp = strtotime($start);
$end = date("Y-m-d\\TH:i:s", $timestamp);
// drupal_set_message('reformatted end: ' . $end);
$row->setSourceProperty('saleend', $end);
}
// Fill in the field_product_ref entity ref to the product node.
$id = $row->getSourceProperty('identifier');
$product_ref_id = $this->lookupProductNid($id);
$row->setSourceProperty('product_ref_id', $product_ref_id);
$tlc = $row->getSourceProperty('tlc');
$store_ref_id = $this->lookupStoreNid($tlc);
$row->setSourceProperty('store_ref_id', $store_ref_id);
$ssid = $row->getSourceProperty('ssid');
drupal_set_message('Processing: ' . $ssid);
/**
* As explained above, we need to pull the style relationships into our
* source row here, as an array of 'style' values (the unique ID for
* the beer_term migration).
*/
// $terms = $this->select('migrate_example_beer_topic_node', 'bt')
// ->fields('bt', ['style'])
// ->condition('bid', $row->getSourceProperty('bid'))
// ->execute()
// ->fetchCol();
// $row->setSourceProperty('terms', $terms);
// As we did for favorite beers in the user migration, we need to explode
// the multi-value country names.
// if ($value = $row->getSourceProperty('countries')) {
// $row->setSourceProperty('countries', explode('|', $value));
// }
return parent::prepareRow($row);
// }
}