コード例 #1
0
 /**
  * {@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
0
 /**
  * {@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
0
 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
0
 /**
  * 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
0
ファイル: RowTest.php プロジェクト: aWEBoLabs/taxi
 /**
  * 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
0
 /**
  * {@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')];
 }