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


PHP Migration::load方法代码示例

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


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

示例1: testNodeType

 /**
  * Tests Drupal 6 node type to Drupal 8 migration.
  */
 public function testNodeType()
 {
     $id_map = Migration::load('d6_node_type')->getIdMap();
     // Test the test_page content type.
     $node_type_page = NodeType::load('test_page');
     $this->assertIdentical('test_page', $node_type_page->id(), 'Node type test_page loaded');
     $this->assertIdentical(TRUE, $node_type_page->displaySubmitted());
     $this->assertIdentical(FALSE, $node_type_page->isNewRevision());
     $this->assertIdentical(DRUPAL_OPTIONAL, $node_type_page->getPreviewMode());
     $this->assertIdentical($id_map->lookupDestinationID(array('test_page')), array('test_page'));
     // Test we have a body field.
     $field = FieldConfig::loadByName('node', 'test_page', 'body');
     $this->assertIdentical('This is the body field label', $field->getLabel(), 'Body field was found.');
     // Test the test_story content type.
     $node_type_story = NodeType::load('test_story');
     $this->assertIdentical('test_story', $node_type_story->id(), 'Node type test_story loaded');
     $this->assertIdentical(TRUE, $node_type_story->displaySubmitted());
     $this->assertIdentical(FALSE, $node_type_story->isNewRevision());
     $this->assertIdentical(DRUPAL_OPTIONAL, $node_type_story->getPreviewMode());
     $this->assertIdentical($id_map->lookupDestinationID(array('test_story')), array('test_story'));
     // Test we don't have a body field.
     $field = FieldConfig::loadByName('node', 'test_story', 'body');
     $this->assertIdentical(NULL, $field, 'No body field found');
     // Test the test_event content type.
     $node_type_event = NodeType::load('test_event');
     $this->assertIdentical('test_event', $node_type_event->id(), 'Node type test_event loaded');
     $this->assertIdentical(TRUE, $node_type_event->displaySubmitted());
     $this->assertIdentical(TRUE, $node_type_event->isNewRevision());
     $this->assertIdentical(DRUPAL_OPTIONAL, $node_type_event->getPreviewMode());
     $this->assertIdentical($id_map->lookupDestinationID(array('test_event')), array('test_event'));
     // Test we have a body field.
     $field = FieldConfig::loadByName('node', 'test_event', 'body');
     $this->assertIdentical('Body', $field->getLabel(), 'Body field was found.');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:37,代码来源:MigrateNodeTypeTest.php

示例2: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('file');
     $this->installEntitySchema('node');
     $this->installSchema('file', ['file_usage']);
     $this->installSchema('node', ['node_access']);
     $id_mappings = array('d6_file' => array());
     // Create new file entities.
     for ($i = 1; $i <= 3; $i++) {
         $file = File::create(array('fid' => $i, 'uid' => 1, 'filename' => 'druplicon.txt', 'uri' => "public://druplicon-{$i}.txt", 'filemime' => 'text/plain', 'created' => 1, 'changed' => 1, 'status' => FILE_STATUS_PERMANENT));
         $file->enforceIsNew();
         file_put_contents($file->getFileUri(), 'hello world');
         // Save it, inserting a new record.
         $file->save();
         $id_mappings['d6_file'][] = array(array($i), array($i));
     }
     $this->prepareMigrations($id_mappings);
     $this->migrateContent();
     // Since we are only testing a subset of the file migration, do not check
     // that the full file migration has been run.
     $migration = Migration::load('d6_upload');
     $migration->set('requirements', []);
     $this->executeMigration($migration);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:28,代码来源:MigrateUploadTest.php

示例3: assertEntity

 /**
  * Asserts various aspects of a migration entity.
  *
  * @param string $id
  *   The migration ID.
  * @param string $label
  *   The label.
  */
 protected function assertEntity($id, $label)
 {
     $migration = Migration::load($id);
     $this->assertTrue($migration instanceof Migration);
     $this->assertIdentical($id, $migration->Id());
     $this->assertIdentical($label, $migration->label());
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:15,代码来源:MigrateNodeBuilderTest.php

示例4: testNode

 /**
  * Test node migration from Drupal 6 to 8.
  */
 public function testNode()
 {
     $node = Node::load(1);
     $this->assertIdentical('1', $node->id(), 'Node 1 loaded.');
     $this->assertIdentical('und', $node->langcode->value);
     $this->assertIdentical('test', $node->body->value);
     $this->assertIdentical('test', $node->body->summary);
     $this->assertIdentical('filtered_html', $node->body->format);
     $this->assertIdentical('story', $node->getType(), 'Node has the correct bundle.');
     $this->assertIdentical('Test title', $node->getTitle(), 'Node has the correct title.');
     $this->assertIdentical('1388271197', $node->getCreatedTime(), 'Node has the correct created time.');
     $this->assertIdentical(FALSE, $node->isSticky());
     $this->assertIdentical('1', $node->getOwnerId());
     $this->assertIdentical('1420861423', $node->getRevisionCreationTime());
     /** @var \Drupal\node\NodeInterface $node_revision */
     $node_revision = \Drupal::entityManager()->getStorage('node')->loadRevision(1);
     $this->assertIdentical('Test title', $node_revision->getTitle());
     $this->assertIdentical('1', $node_revision->getRevisionAuthor()->id(), 'Node revision has the correct user');
     // This is empty on the first revision.
     $this->assertIdentical(NULL, $node_revision->revision_log->value);
     // Test that we can re-import using the EntityContentBase destination.
     $connection = Database::getConnection('default', 'migrate');
     $connection->update('node_revisions')->fields(array('title' => 'New node title', 'format' => 2))->condition('vid', 1)->execute();
     $connection->delete('content_field_test_two')->condition('delta', 1)->execute();
     $migration = Migration::load('d6_node__story');
     $this->executeMigration($migration);
     $node = Node::load(1);
     $this->assertIdentical('New node title', $node->getTitle());
     // Test a multi-column fields are correctly upgraded.
     $this->assertIdentical('test', $node->body->value);
     $this->assertIdentical('full_html', $node->body->format);
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:35,代码来源:MigrateNodeTest.php

示例5: overview

 /**
  * Displays a listing of migration messages.
  *
  * Messages are truncated at 56 chars.
  *
  * @return array
  *   A render array as expected by drupal_render().
  */
 public function overview($migration_group, $migration)
 {
     $rows = [];
     $classes = static::getLogLevelClassMap();
     /** @var MigrationInterface $migration */
     $migration = Migration::load($migration);
     $source_id_field_names = array_keys($migration->getSourcePlugin()->getIds());
     $column_number = 1;
     foreach ($source_id_field_names as $source_id_field_name) {
         $header[] = ['data' => $source_id_field_name, 'field' => 'sourceid' . $column_number++, 'class' => [RESPONSIVE_PRIORITY_MEDIUM]];
     }
     $header[] = ['data' => $this->t('Severity level'), 'field' => 'level', 'class' => [RESPONSIVE_PRIORITY_LOW]];
     $header[] = ['data' => $this->t('Message'), 'field' => 'message'];
     $message_table = $migration->getIdMap()->messageTableName();
     $query = $this->database->select($message_table, 'm')->extend('\\Drupal\\Core\\Database\\Query\\PagerSelectExtender')->extend('\\Drupal\\Core\\Database\\Query\\TableSortExtender');
     $query->fields('m');
     $result = $query->limit(50)->orderByHeader($header)->execute();
     foreach ($result as $message_row) {
         $column_number = 1;
         foreach ($source_id_field_names as $source_id_field_name) {
             $column_name = 'sourceid' . $column_number++;
             $row[$column_name] = $message_row->{$column_name};
         }
         $row['level'] = $message_row->level;
         $row['message'] = $message_row->message;
         $row['class'] = [Html::getClass('migrate-message-' . $message_row->level), $classes[$message_row->level]];
         $rows[] = $row;
     }
     $build['message_table'] = ['#type' => 'table', '#header' => $header, '#rows' => $rows, '#attributes' => ['id' => $message_table, 'class' => [$message_table]], '#empty' => $this->t('No messages for this migration.')];
     $build['message_pager'] = ['#type' => 'pager'];
     return $build;
 }
开发者ID:sheldonrampton,项目名称:drupal8-drops,代码行数:40,代码来源:MessageController.php

示例6: testUserRole

 /**
  * Tests user role migration.
  */
 public function testUserRole()
 {
     /** @var \Drupal\migrate\entity\Migration $migration */
     $id_map = Migration::load('d6_user_role')->getIdMap();
     $rid = 'anonymous';
     $anonymous = Role::load($rid);
     $this->assertIdentical($rid, $anonymous->id());
     $this->assertIdentical(array('migrate test anonymous permission', 'use text format filtered_html'), $anonymous->getPermissions());
     $this->assertIdentical(array($rid), $id_map->lookupDestinationId(array(1)));
     $rid = 'authenticated';
     $authenticated = Role::load($rid);
     $this->assertIdentical($rid, $authenticated->id());
     $this->assertIdentical(array('migrate test authenticated permission', 'use text format filtered_html'), $authenticated->getPermissions());
     $this->assertIdentical(array($rid), $id_map->lookupDestinationId(array(2)));
     $rid = 'migrate_test_role_1';
     $migrate_test_role_1 = Role::load($rid);
     $this->assertIdentical($rid, $migrate_test_role_1->id());
     $this->assertIdentical(array('migrate test role 1 test permission', 'use text format full_html', 'use text format php_code'), $migrate_test_role_1->getPermissions());
     $this->assertIdentical(array($rid), $id_map->lookupDestinationId(array(3)));
     $rid = 'migrate_test_role_2';
     $migrate_test_role_2 = Role::load($rid);
     $this->assertIdentical(array('migrate test role 2 test permission', 'use PHP for settings', 'administer contact forms', 'skip comment approval', 'edit own blog content', 'edit any blog content', 'delete own blog content', 'delete any blog content', 'create forum content', 'delete any forum content', 'delete own forum content', 'edit any forum content', 'edit own forum content', 'administer nodes', 'access content overview', 'use text format php_code'), $migrate_test_role_2->getPermissions());
     $this->assertIdentical($rid, $migrate_test_role_2->id());
     $this->assertIdentical(array($rid), $id_map->lookupDestinationId(array(4)));
     $rid = 'migrate_test_role_3_that_is_long';
     $migrate_test_role_3 = Role::load($rid);
     $this->assertIdentical($rid, $migrate_test_role_3->id());
     $this->assertIdentical(array($rid), $id_map->lookupDestinationId(array(5)));
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:32,代码来源:MigrateUserRoleTest.php

示例7: import

 /**
  * Drush execution method. Runs imports on the supplied manifest.
  */
 public function import()
 {
     /** @var \Drupal\migrate\MigrateTemplateStorage $template_storage */
     $template_storage = \Drupal::service('migrate.template_storage');
     $this->setupLegacyDb();
     $migration_ids = [];
     $migrations = [];
     foreach ($this->migrationList as $migration_info) {
         if (is_array($migration_info)) {
             // The migration is stored as the key in the info array.
             $migration_id = key($migration_info);
         } else {
             // If it wasn't an array then the info is just the migration_id.
             $migration_id = $migration_info;
         }
         $template = $template_storage->getTemplateByName($migration_id) ?: [];
         if (is_array($migration_info)) {
             // If there is some existing global overrides then we merge them in.
             if (isset($GLOBALS['config'][$migration_id])) {
                 $migration_info = NestedArray::mergeDeep($GLOBALS['config'][$migration_id], $migration_info);
             }
             $migration_info = NestedArray::mergeDeep($template, $migration_info);
         } else {
             $migration_info = $template;
         }
         if ($migration_info) {
             /** @var \Drupal\migrate\Entity\Migration[] $migrations */
             $migrations = \Drupal::service('migrate.migration_builder')->createMigrations([$migration_id => $migration_info]);
             foreach ($migrations as $migration) {
                 $migration_ids[] = $migration->id();
                 if (!Migration::load($migration->id())) {
                     $migration->save();
                 }
             }
             // We use these migration_ids to run migrations. If we didn't create
             // anything we pass it on and this will trigger non-existent migrations
             // messages or resolved by migration loading.
             // @todo this can return false positives in the non-existent migration
             // logic if the builder explicitly returned no results. For example, no
             // taxonomies will cause some things to be empty.
             if (!$migrations) {
                 $migration_ids[] = $migration_id;
             }
         }
     }
     // Load all the migrations at once so they're correctly ordered.
     foreach (Migration::loadMultiple($migration_ids) as $migration) {
         $executable = $this->executeMigration($migration);
         // Store all the migrations for later.
         $migrations[$migration->id()] = array('executable' => $executable, 'migration' => $migration, 'source' => $migration->get('source'), 'destination' => $migration->get('destination'));
     }
     // Warn the user if any migrations were not found.
     $nonexistent_migrations = array_diff($migration_ids, array_keys($migrations));
     if (count($nonexistent_migrations) > 0) {
         drush_log(dt('The following migrations were not found: @migrations', array('@migrations' => implode(', ', $nonexistent_migrations))), 'warning');
     }
     return $migrations;
 }
开发者ID:atxajon,项目名称:d8cafe,代码行数:61,代码来源:MigrateManifest.php

示例8: testViewModes

 /**
  * Tests Drupal 6 view modes to Drupal 8 migration.
  */
 public function testViewModes()
 {
     // Test a new view mode.
     $view_mode = EntityViewMode::load('node.preview');
     $this->assertIdentical(FALSE, is_null($view_mode), 'Preview view mode loaded.');
     $this->assertIdentical('Preview', $view_mode->label(), 'View mode has correct label.');
     // Test the ID map.
     $this->assertIdentical(array('node', 'preview'), Migration::load('d6_view_modes')->getIdMap()->lookupDestinationID(array(1)));
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:12,代码来源:MigrateViewModesTest.php

示例9: testVocabularyEntityFormDisplay

 /**
  * Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
  */
 public function testVocabularyEntityFormDisplay()
 {
     // Test that the field exists.
     $component = EntityFormDisplay::load('node.page.default')->getComponent('tags');
     $this->assertIdentical('options_select', $component['type']);
     $this->assertIdentical(20, $component['weight']);
     // Test the Id map.
     $this->assertIdentical(array('node', 'article', 'default', 'tags'), Migration::load('d6_vocabulary_entity_form_display')->getIdMap()->lookupDestinationID(array(4, 'article')));
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:12,代码来源:MigrateVocabularyEntityFormDisplayTest.php

示例10: testVocabularyField

 /**
  * Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
  */
 public function testVocabularyField()
 {
     // Test that the field exists.
     $field_storage_id = 'node.tags';
     $field_storage = FieldStorageConfig::load($field_storage_id);
     $this->assertIdentical($field_storage_id, $field_storage->id());
     $settings = $field_storage->getSettings();
     $this->assertIdentical('taxonomy_term', $settings['target_type'], "Target type is correct.");
     $this->assertIdentical(array('node', 'tags'), Migration::load('d6_vocabulary_field')->getIdMap()->lookupDestinationID(array(4)), "Test IdMap");
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:13,代码来源:MigrateVocabularyFieldTest.php

示例11: testAggregatorMigrateDependencies

 /**
  * Tests dependencies on the migration of aggregator feeds & items.
  */
 public function testAggregatorMigrateDependencies()
 {
     /** @var \Drupal\migrate\entity\Migration $migration */
     $migration = Migration::load('d6_aggregator_item');
     $executable = new MigrateExecutable($migration, $this);
     $this->startCollectingMessages();
     $executable->import();
     $this->assertEqual($this->migrateMessages['error'], array(SafeMarkup::format('Migration @id did not meet the requirements. Missing migrations d6_aggregator_feed. requirements: d6_aggregator_feed.', array('@id' => $migration->id()))));
     $this->collectMessages = FALSE;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:13,代码来源:MigrateDependenciesTest.php

示例12: testMissingTable

 /**
  * Tests that an exception is thrown when ImageCache is not installed.
  */
 public function testMissingTable()
 {
     $this->sourceDatabase->update('system')->fields(array('status' => 0))->condition('name', 'imagecache')->condition('type', 'module')->execute();
     try {
         Migration::load('d6_imagecache_presets')->getSourcePlugin()->checkRequirements();
         $this->fail('Did not catch expected RequirementsException.');
     } catch (RequirementsException $e) {
         $this->pass('Caught expected RequirementsException: ' . $e->getMessage());
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:13,代码来源:MigrateImageCacheTest.php

示例13: testSkipNonExistentNode

 /**
  * Tests that term associations are ignored when they belong to nodes which
  * were not migrated.
  */
 public function testSkipNonExistentNode()
 {
     // Node 2 is migrated by d6_node__story, but we need to pretend that it
     // failed, so record that in the map table.
     $this->mockFailure('d6_node__story', ['nid' => 2]);
     // d6_term_node__2 should skip over node 2 (a.k.a. revision 3) because,
     // according to the map table, it failed.
     $migration = Migration::load('d6_term_node__2');
     $this->executeMigration($migration);
     $this->assertNull($migration->getIdMap()->lookupDestinationId(['vid' => 3])[0]);
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:15,代码来源:MigrateTermNodeTest.php

示例14: testUser

 /**
  * Tests the Drupal6 user to Drupal 8 migration.
  */
 public function testUser()
 {
     $users = Database::getConnection('default', 'migrate')->select('users', 'u')->fields('u')->condition('uid', 0, '>')->execute()->fetchAll();
     foreach ($users as $source) {
         // Get roles directly from the source.
         $rids = Database::getConnection('default', 'migrate')->select('users_roles', 'ur')->fields('ur', array('rid'))->condition('ur.uid', $source->uid)->execute()->fetchCol();
         $roles = array(RoleInterface::AUTHENTICATED_ID);
         $id_map = Migration::load('d6_user_role')->getIdMap();
         foreach ($rids as $rid) {
             $role = $id_map->lookupDestinationId(array($rid));
             $roles[] = reset($role);
         }
         /** @var \Drupal\user\UserInterface $user */
         $user = User::load($source->uid);
         $this->assertIdentical($source->uid, $user->id());
         $this->assertIdentical($source->name, $user->label());
         $this->assertIdentical($source->mail, $user->getEmail());
         $this->assertIdentical($source->created, $user->getCreatedTime());
         $this->assertIdentical($source->access, $user->getLastAccessedTime());
         $this->assertIdentical($source->login, $user->getLastLoginTime());
         $is_blocked = $source->status == 0;
         $this->assertIdentical($is_blocked, $user->isBlocked());
         // $user->getPreferredLangcode() might fallback to default language if the
         // user preferred language is not configured on the site. We just want to
         // test if the value was imported correctly.
         $this->assertIdentical($source->language, $user->preferred_langcode->value);
         $expected_timezone_name = $source->timezone_name ?: $this->config('system.date')->get('timezone.default');
         $this->assertIdentical($expected_timezone_name, $user->getTimeZone());
         $this->assertIdentical($source->init, $user->getInitialEmail());
         $this->assertIdentical($roles, $user->getRoles());
         // We have one empty picture in the data so don't try load that.
         if (!empty($source->picture)) {
             // Test the user picture.
             $file = File::load($user->user_picture->target_id);
             $this->assertIdentical(basename($source->picture), $file->getFilename());
         }
         // Use the API to check if the password has been salted and re-hashed to
         // conform to Drupal >= 7 for non-admin users.
         if ($user->id() != 1) {
             $this->assertTrue(\Drupal::service('password')->check($source->pass_plain, $user->getPassword()));
         }
     }
     // Rollback the migration and make sure everything is deleted but uid 1.
     (new MigrateExecutable($this->migration, $this))->rollback();
     $users = Database::getConnection('default', 'migrate')->select('users', 'u')->fields('u', ['uid'])->condition('uid', 0, '>')->execute()->fetchCol();
     foreach ($users as $uid) {
         $account = User::load($uid);
         if ($uid == 1) {
             $this->assertNotNull($account, 'User 1 was preserved after rollback');
         } else {
             $this->assertNull($account);
         }
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:57,代码来源:MigrateUserTest.php

示例15: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('file');
     /** @var \Drupal\migrate\Entity\MigrationInterface $migration */
     $migration = Migration::load('d6_user_picture_file');
     $source = $migration->get('source');
     $source['site_path'] = 'core/modules/simpletest';
     $migration->set('source', $source);
     $this->executeMigration($migration);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:14,代码来源:MigrateUserPictureFileTest.php


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