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


PHP Migration::create方法代码示例

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


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

示例1: buildMigrations

 /**
  * {@inheritdoc}
  */
 public function buildMigrations(array $template)
 {
     $migrations = [];
     // Read all field instance definitions in the source database.
     $fields = array();
     foreach ($this->getSourcePlugin('d7_field_instance', $template['source']) as $field) {
         $info = $field->getSource();
         $fields[$info['entity_type']][$info['bundle']][$info['field_name']] = $info;
     }
     foreach ($this->getSourcePlugin('d7_node_type', $template['source']) as $node_type) {
         $bundle = $node_type->getSourceProperty('type');
         $values = $template;
         $values['id'] .= '__' . $bundle;
         $values['label'] = $this->t('@label (@type)', ['@label' => $values['label'], '@type' => $node_type->getSourceProperty('name')]);
         $values['source']['node_type'] = $bundle;
         $migration = Migration::create($values);
         if (isset($fields['node'][$bundle])) {
             foreach ($fields['node'][$bundle] as $field => $data) {
                 if ($this->cckPluginManager->hasDefinition($data['type'])) {
                     $this->getCckPlugin($data['type'])->processCckFieldValues($migration, $field, $data);
                 } else {
                     $migration->setProcessOfProperty($field, $field);
                 }
             }
         }
         $migrations[] = $migration;
     }
     return $migrations;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:32,代码来源:Node.php

示例2: buildMigrations

 /**
  * {@inheritdoc}
  */
 public function buildMigrations(array $template)
 {
     $migrations = [];
     // Read all CCK field instance definitions in the source database.
     $fields = array();
     foreach ($this->getSourcePlugin('d6_field_instance', $template['source']) as $field) {
         $info = $field->getSource();
         $fields[$info['type_name']][$info['field_name']] = $info;
     }
     foreach ($this->getSourcePlugin('d6_node_type', $template['source']) as $row) {
         $node_type = $row->getSourceProperty('type');
         $values = $template;
         $values['id'] = $template['id'] . '__' . $node_type;
         $label = $template['label'];
         $values['label'] = $this->t("@label (@type)", ['@label' => $label, '@type' => $node_type]);
         $values['source']['node_type'] = $node_type;
         $migration = Migration::create($values);
         if (isset($fields[$node_type])) {
             foreach ($fields[$node_type] as $field => $info) {
                 if ($this->cckPluginManager->hasDefinition($info['type'])) {
                     $this->getCckPlugin($info['type'])->processCckFieldValues($migration, $field, $info);
                 } else {
                     $migration->setProcessOfProperty($field, $field);
                 }
             }
         }
         $migrations[] = $migration;
     }
     return $migrations;
 }
开发者ID:komejo,项目名称:article-test,代码行数:33,代码来源:Node.php

示例3: testEmbeddedData

 /**
  * Tests the embedded_data source plugin.
  */
 public function testEmbeddedData()
 {
     $data_rows = [['key' => '1', 'field1' => 'f1value1', 'field2' => 'f2value1'], ['key' => '2', 'field1' => 'f1value2', 'field2' => 'f2value2']];
     $ids = ['key' => ['type' => 'integer']];
     $config = ['id' => 'sample_data', 'migration_tags' => ['Embedded data test'], 'source' => ['plugin' => 'embedded_data', 'data_rows' => $data_rows, 'ids' => $ids], 'process' => [], 'destination' => ['plugin' => 'null']];
     $migration = Migration::create($config);
     $source = $migration->getSourcePlugin();
     // Validate the plugin returns the source data that was provided.
     $results = [];
     /** @var Row $row */
     foreach ($source as $row) {
         $data_row = $row->getSource();
         // The "data" row returned by getSource() also includes all source
         // configuration - we remove it so we see only the data itself.
         unset($data_row['plugin']);
         unset($data_row['data_rows']);
         unset($data_row['ids']);
         $results[] = $data_row;
     }
     $this->assertIdentical($results, $data_rows);
     // Validate the public APIs.
     $this->assertIdentical($source->count(), count($data_rows));
     $this->assertIdentical($source->getIds(), $ids);
     $expected_fields = ['key' => 'key', 'field1' => 'field1', 'field2' => 'field2'];
     $this->assertIdentical($source->fields(), $expected_fields);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:29,代码来源:MigrateEmbeddedDataTest.php

示例4: buildMigrations

 /**
  * {@inheritdoc}
  */
 public function buildMigrations(array $template)
 {
     $migrations = [];
     $fields = [];
     foreach ($this->getSourcePlugin('d7_field_instance', $template['source']) as $field) {
         $entity_type = $field->getSourceProperty('entity_type');
         $bundle = $field->getSourceProperty('bundle');
         $field_name = $field->getSourceProperty('field_name');
         $fields[$entity_type][$bundle][$field_name] = $field->getSource();
     }
     foreach ($this->getSourcePlugin('d7_node_type', $template['source']) as $node_type) {
         $bundle = $node_type->getSourceProperty('type');
         $values = $template;
         $values['id'] .= '__' . $bundle;
         $values['label'] = $this->t('@label (@type)', ['@label' => $values['label'], '@type' => $node_type->getSourceProperty('name')]);
         $values['source']['node_type'] = $bundle;
         $migration = Migration::create($values);
         if (isset($fields['node'][$bundle])) {
             foreach (array_keys($fields['node'][$bundle]) as $field) {
                 $migration->setProcessOfProperty($field, $field);
             }
         }
         $migrations[] = $migration;
     }
     return $migrations;
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:29,代码来源:Node.php

示例5: buildMigrations

 /**
  * {@inheritdoc}
  */
 public function buildMigrations(array $template)
 {
     $migration = Migration::create($template);
     $source_plugin = $migration->getSourcePlugin();
     // The source plugin will throw RequirementsException if CCK is not enabled,
     // in which case there is nothing else for us to do.
     if ($source_plugin instanceof RequirementsInterface) {
         try {
             $source_plugin->checkRequirements();
         } catch (RequirementsException $e) {
             return [$migration];
         }
     }
     // Loop through every field that will be migrated.
     foreach ($source_plugin as $field) {
         $field_type = $field->getSourceProperty('type');
         // Each field type should only be processed once.
         if (in_array($field_type, $this->processedFieldTypes)) {
             continue;
         } elseif ($this->cckPluginManager->hasDefinition($field_type)) {
             $this->processedFieldTypes[] = $field_type;
             // Allow the cckfield plugin to alter the migration as necessary so that
             // it knows how to handle fields of this type.
             $this->cckPluginManager->createInstance($field_type, [], $migration)->{$this->configuration['cck_plugin_method']}($migration);
         }
     }
     return [$migration];
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:31,代码来源:CckMigration.php

示例6: testStubWithWeightMapping

 /**
  * Tests creation of stubs when weight is mapped.
  */
 public function testStubWithWeightMapping()
 {
     // Create a vocabulary via migration for the terms to reference.
     $vocabulary_data_rows = [['id' => '1', 'name' => 'tags']];
     $ids = ['id' => ['type' => 'integer']];
     $config = ['id' => 'vocabularies', 'migration_tags' => ['Stub test'], 'source' => ['plugin' => 'embedded_data', 'data_rows' => $vocabulary_data_rows, 'ids' => $ids], 'process' => ['vid' => 'id', 'name' => 'name'], 'destination' => ['plugin' => 'entity:taxonomy_vocabulary']];
     $vocabulary_migration = Migration::create($config);
     $vocabulary_executable = new MigrateExecutable($vocabulary_migration, $this);
     $vocabulary_executable->import();
     // We have a term referencing an unmigrated parent, forcing a stub to be
     // created.
     $term_data_rows = [['id' => '1', 'vocab' => '1', 'name' => 'music', 'parent' => '2']];
     $ids = ['id' => ['type' => 'integer']];
     $config = ['id' => 'terms', 'migration_tags' => ['Import and rollback test'], 'source' => ['plugin' => 'embedded_data', 'data_rows' => $term_data_rows, 'ids' => $ids], 'process' => ['tid' => 'id', 'vid' => 'vocab', 'name' => 'name', 'weight' => 'weight', 'parent' => ['plugin' => 'migration', 'migration' => 'terms', 'source' => 'parent']], 'destination' => ['plugin' => 'entity:taxonomy_term'], 'migration_dependencies' => ['required' => ['vocabularies']]];
     $term_migration = Migration::create($config);
     $term_migration->save();
     $term_executable = new MigrateExecutable($term_migration, $this);
     $term_executable->import();
     // Load the referenced term, which should exist as a stub.
     /** @var \Drupal\Core\Entity\ContentEntityBase $stub_entity */
     $stub_entity = Term::load(2);
     $this->assertTrue($stub_entity, 'Stub successfully created');
     if ($stub_entity) {
         $this->assertIdentical(count($stub_entity->validate()), 0, 'Stub is a valid entity');
     }
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:29,代码来源:MigrateTaxonomyTermStubTest.php

示例7: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->installConfig(['system']);
     // A simple migration, which will generate a message to the id map because
     // the concat plugin throws an exception if its source is not an array.
     $config = ['id' => 'sample_data', 'migration_tags' => ['Message test'], 'source' => ['plugin' => 'embedded_data', 'data_rows' => [['name' => 'source_message', 'value' => 'a message']], 'ids' => ['name' => ['type' => 'string']]], 'process' => ['message' => ['plugin' => 'concat', 'source' => 'value']], 'destination' => ['plugin' => 'config', 'config_name' => 'system.maintenance']];
     $this->migration = Migration::create($config);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:12,代码来源:MigrateMessageTest.php

示例8: createStub

 /**
  * Create a stub of the given entity type.
  *
  * @param string $entity_type_id
  *   The entity type we are stubbing.
  *
  * @return int
  *   ID of the created entity.
  */
 protected function createStub($entity_type_id)
 {
     // Create a dummy migration to pass to the destination plugin.
     $config = ['id' => 'dummy', 'migration_tags' => ['Stub test'], 'source' => ['plugin' => 'empty'], 'process' => [], 'destination' => ['plugin' => 'entity:' . $entity_type_id]];
     $migration = Migration::create($config);
     $destination_plugin = $migration->getDestinationPlugin(TRUE);
     $stub_row = new Row([], [], TRUE);
     $destination_ids = $destination_plugin->import($stub_row);
     return reset($destination_ids);
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:19,代码来源:StubTestTrait.php

示例9: testSetInvalidation

 /**
  * Tests Migration::set()
  *
  * @covers ::set()
  */
 public function testSetInvalidation()
 {
     $migration = Migration::create(['source' => ['plugin' => 'empty'], 'destination' => ['plugin' => 'entity:entity_view_mode']]);
     $this->assertEqual('empty', $migration->getSourcePlugin()->getPluginId());
     $this->assertEqual('entity:entity_view_mode', $migration->getDestinationPlugin()->getPluginId());
     // Test the source plugin is invalidated.
     $migration->set('source', ['plugin' => 'd6_field']);
     $this->assertEqual('d6_field', $migration->getSourcePlugin()->getPluginId());
     // Test the destination plugin is invalidated.
     $migration->set('destination', ['plugin' => 'null']);
     $this->assertEqual('null', $migration->getDestinationPlugin()->getPluginId());
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:17,代码来源:MigrationTest.php

示例10: testCalculateDependencies

 /**
  * @covers ::calculateDependencies
  */
 public function testCalculateDependencies()
 {
     $fixture_migrations = ['d6_node__article' => 'd6_node', 'd6_node__page' => 'd6_node', 'd6_variables' => 'd6_variables'];
     foreach ($fixture_migrations as $id => $template) {
         $values = ['id' => $id, 'template' => $template, 'source' => ['plugin' => 'empty'], 'destination' => ['plugin' => 'null'], 'migration_tags' => []];
         Migration::create($values)->save();
     }
     $values = ['migration_dependencies' => ['required' => ['d6_node:*', 'd6_variables']], 'source' => ['plugin' => 'empty'], 'destination' => ['plugin' => 'null']];
     $migration = new Migration($values, 'migration');
     $expected = ['migrate.migration.d6_node__article', 'migrate.migration.d6_node__page', 'migrate.migration.d6_variables'];
     $migration->calculateDependencies();
     $this->assertEquals($expected, $migration->getDependencies()['config']);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:16,代码来源:MigrationTest.php

示例11: testMigrateEvents

 /**
  * Tests migration interruptions.
  */
 public function testMigrateEvents()
 {
     // Run a simple little migration, which should trigger one of each event
     // other than map_delete.
     $config = ['id' => 'sample_data', 'migration_tags' => ['Interruption test'], 'source' => ['plugin' => 'embedded_data', 'data_rows' => [['data' => 'dummy value'], ['data' => 'dummy value2']], 'ids' => ['data' => ['type' => 'string']]], 'process' => ['value' => 'data'], 'destination' => ['plugin' => 'dummy']];
     $migration = Migration::create($config);
     /** @var MigrationInterface $migration */
     $executable = new MigrateExecutable($migration, new MigrateMessage());
     // When the import runs, the first row imported will trigger an interruption.
     $result = $executable->import();
     $this->assertEqual($result, MigrationInterface::RESULT_INCOMPLETE);
     // The status should have been reset to IDLE.
     $this->assertEqual($migration->getStatus(), MigrationInterface::STATUS_IDLE);
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:17,代码来源:MigrateInterruptionTest.php

示例12: getSourcePlugin

 /**
  * Returns a fully initialized instance of a source plugin.
  *
  * @param string $plugin_id
  *   The plugin ID.
  * @param array $configuration
  *   (optional) Additional configuration for the plugin.
  *
  * @return \Drupal\migrate\Plugin\MigrateSourceInterface|\Drupal\migrate\Plugin\RequirementsInterface
  *   The fully initialized source plugin.
  */
 protected function getSourcePlugin($plugin_id, array $configuration = [])
 {
     $configuration['plugin'] = $plugin_id;
     // By default, SqlBase subclasses will try to join on a map table. But in
     // this case we're trying to use the source plugin as a detached iterator
     // over the source data, so we don't want to join on (or create) the map
     // table.
     // @see SqlBase::initializeIterator()
     $configuration['ignore_map'] = TRUE;
     // Source plugins are tightly coupled to migration entities, so we need
     // to create a fake migration in order to properly initialize the plugin.
     $values = ['id' => uniqid(), 'source' => $configuration, 'destination' => ['plugin' => 'null']];
     return Migration::create($values)->getSourcePlugin();
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:25,代码来源:BuilderBase.php

示例13: installMigrations

 /**
  * Turn all the migration templates for the specified drupal version into
  * real migration entities so we can test them.
  *
  * @param string $version
  *  Drupal version as provided in migration_tags - e.g., 'Drupal 6'.
  */
 protected function installMigrations($version)
 {
     $migration_templates = \Drupal::service('migrate.template_storage')->findTemplatesByTag($version);
     foreach ($migration_templates as $template) {
         try {
             $migration = Migration::create($template);
             $migration->save();
         } catch (PluginNotFoundException $e) {
             // Migrations requiring modules not enabled will throw an exception.
             // Ignoring this exception is equivalent to placing config in the
             // optional subdirectory - the migrations we require for the test will
             // be successfully saved.
         }
     }
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:22,代码来源:MigrateDrupalTestBase.php

示例14: buildMigrations

 /**
  * {@inheritdoc}
  */
 public function buildMigrations(array $template)
 {
     $migration = Migration::create($template);
     // @TODO The source plugin should accept a database connection.
     // @see https://www.drupal.org/node/2552791
     $source_plugin = $this->getSourcePlugin('d6_profile_field', $template['source']);
     try {
         $source_plugin->checkRequirements();
     } catch (RequirementsException $e) {
         return [];
     }
     foreach ($source_plugin as $field) {
         $migration->setProcessOfProperty($field->getSourceProperty('name'), $field->getSourceProperty('name'));
     }
     return [$migration];
 }
开发者ID:scratch,项目名称:gai,代码行数:19,代码来源:ProfileValues.php

示例15: testStatus

 /**
  * Test different connection types.
  */
 public function testStatus()
 {
     // Create a minimally valid migration.
     $configuration = ['id' => 'migration_status_test', 'migration_tags' => ['Testing'], 'source' => ['plugin' => 'empty'], 'destination' => ['plugin' => 'config', 'config_name' => 'migrate_test.settings'], 'process' => ['foo' => 'bar']];
     $migration = Migration::create($configuration);
     $migration->save();
     // Default status is idle.
     $status = $migration->getStatus();
     $this->assertIdentical($status, MigrationInterface::STATUS_IDLE);
     // Test setting and retrieving all known status values.
     $status_list = array(MigrationInterface::STATUS_IDLE, MigrationInterface::STATUS_IMPORTING, MigrationInterface::STATUS_ROLLING_BACK, MigrationInterface::STATUS_STOPPING, MigrationInterface::STATUS_DISABLED);
     foreach ($status_list as $status) {
         $migration->setStatus($status);
         $this->assertIdentical($migration->getStatus(), $status);
     }
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:19,代码来源:MigrateStatusTest.php


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