本文整理汇总了PHP中Drupal\migrate\Row::getDestination方法的典型用法代码示例。如果您正苦于以下问题:PHP Row::getDestination方法的具体用法?PHP Row::getDestination怎么用?PHP Row::getDestination使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\migrate\Row
的用法示例。
在下文中一共展示了Row::getDestination方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import
/**
* {@inheritdoc}
*/
public function import(Row $row, array $old_destination_id_values = array())
{
$destination = $row->getDestination();
$langcode = $destination['default_langcode'];
// Check if the language exists.
if (ConfigurableLanguage::load($langcode) === NULL) {
throw new MigrateException("The language '{$langcode}' does not exist on this site.");
}
$this->config->set('default_langcode', $destination['default_langcode']);
$this->config->save();
return [$this->config->getName()];
}
示例2: import
/**
* {@inheritdoc}
*/
public function import(Row $row, array $old_destination_id_values = array())
{
$destination = $row->getDestination();
$keys = array();
foreach (array_keys($this->ids) as $id) {
$keys[$id] = $destination[$id];
unset($destination[$id]);
}
\Drupal::database()->merge($this->table_name)->keys($keys)->fields($destination)->execute();
$return = array_map(function ($key) use($row) {
return $row->getDestinationProperty($key);
}, $keys);
return $return;
}
示例3: transform
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
{
$entity_type = $row->getDestination()['type'];
$definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', $entity_type);
if (isset($definitions[$destination_property])) {
$vid = $this->configuration['vid'];
$tid_qry = db_select('taxonomy_term_field_data', 't')->fields('t', array('tid'))->condition('name', $value)->execute();
$db_row = $tid_qry->fetchAssoc();
if ($db_row !== FALSE) {
return $db_row['tid'];
} else {
trigger_error("Missing term '{$value}' under vid '{$vid}'", E_USER_WARNING);
return array();
}
}
}
示例4: updateEntity
/**
* Update an entity with the new values from row.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to update.
* @param \Drupal\migrate\Row $row
* The row object to update from.
*/
protected function updateEntity(EntityInterface $entity, Row $row)
{
foreach ($row->getDestination() as $field_name => $values) {
$field = $entity->{$field_name};
if ($field instanceof TypedDataInterface) {
$field->setValue($values);
}
}
}
示例5: testMultipleDestination
/**
* Tests setting/getting multiple destination IDs.
*/
public function testMultipleDestination()
{
$row = new Row($this->testValues, $this->testSourceIds);
// Set some deep nested values.
$row->setDestinationProperty('image/alt', 'alt text');
$row->setDestinationProperty('image/fid', 3);
$this->assertTrue($row->hasDestinationProperty('image'));
$this->assertFalse($row->hasDestinationProperty('alt'));
$this->assertFalse($row->hasDestinationProperty('fid'));
$destination = $row->getDestination();
$this->assertEquals('alt text', $destination['image']['alt']);
$this->assertEquals(3, $destination['image']['fid']);
$this->assertEquals('alt text', $row->getDestinationProperty('image/alt'));
$this->assertEquals(3, $row->getDestinationProperty('image/fid'));
}
示例6: import
/**
* {@inheritdoc}
*/
public function import(Row $row, array $old_destination_id_values = array())
{
$destination = $row->getDestination();
\Drupal::database()->merge('acl')->key(array('acl_id' => $destination['acl_id']))->fields(array('module' => $destination['module'], 'name' => $destination['name'], 'figure' => $destination['figure']))->execute();
return [$row->getDestinationProperty('acl_id')];
}