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


PHP entity_load_unchanged函数代码示例

本文整理汇总了PHP中entity_load_unchanged函数的典型用法代码示例。如果您正苦于以下问题:PHP entity_load_unchanged函数的具体用法?PHP entity_load_unchanged怎么用?PHP entity_load_unchanged使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: testWidget

 /**
  * Tests the widget.
  */
 protected function testWidget()
 {
     $user = $this->drupalCreateUser(['administer user fields']);
     $this->drupalLogin($user);
     // Test the widget when setting a default field value.
     $field_name = strtolower($this->randomMachineName());
     $selectable_plugin_type_id = 'block';
     $field_type = 'plugin:' . $selectable_plugin_type_id;
     $default_selected_plugin_id = 'broken';
     $this->drupalPostForm('admin/config/people/accounts/fields/add-field', ['label' => $this->randomString(), 'field_name' => $field_name, 'new_storage_type' => $field_type], t('Save and continue'));
     $this->drupalPostForm(NULL, [], t('Save field settings'));
     $this->drupalPostForm(NULL, [sprintf('default_value_input[field_%s][0][plugin_selector][container][select][container][plugin_id]', $field_name) => $default_selected_plugin_id], t('Choose'));
     $this->drupalPostForm(NULL, [], t('Save settings'));
     \Drupal::entityManager()->clearCachedFieldDefinitions();
     // Get all plugin fields.
     $field_storage_id = 'user.field_' . $field_name;
     $field_storage = FieldStorageConfig::load($field_storage_id);
     $this->assertNotNull($field_storage);
     $field_id = 'user.user.field_' . $field_name;
     /** @var \Drupal\field\FieldConfigInterface $field */
     $field = FieldConfig::load($field_id);
     $this->assertNotNull($field);
     $this->assertEqual($field->getDefaultValueLiteral()[0]['plugin_type_id'], $selectable_plugin_type_id);
     $this->assertEqual($field->getDefaultValueLiteral()[0]['plugin_id'], $default_selected_plugin_id);
     $this->assertTrue(is_array($field->getDefaultValueLiteral()[0]['plugin_configuration']));
     // Test the widget when creating an entity.
     $entity_selected_plugin_id = 'system_breadcrumb_block';
     $this->drupalPostForm('user/' . $user->id() . '/edit', [sprintf('field_%s[0][plugin_selector][container][select][container][plugin_id]', $field_name) => $entity_selected_plugin_id], t('Choose'));
     $this->drupalPostForm(NULL, [], t('Save'));
     // Test whether the widget displays field values.
     /** @var \Drupal\Core\Entity\ContentEntityInterface $user */
     $user = entity_load_unchanged('user', $user->id());
     $this->assertEqual($user->get('field_' . $field_name)->get(0)->get('plugin_type_id')->getValue(), $selectable_plugin_type_id);
     $this->assertEqual($user->get('field_' . $field_name)->get(0)->get('plugin_id')->getValue(), $entity_selected_plugin_id);
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:38,代码来源:PluginSelectorTest.php

示例2: testFiles

 /**
  * Tests the Drupal 6 files to Drupal 8 migration.
  */
 public function testFiles()
 {
     /** @var \Drupal\file\FileInterface $file */
     $file = entity_load('file', 1);
     $this->assertIdentical('Image1.png', $file->getFilename());
     $this->assertIdentical('39325', $file->getSize());
     $this->assertIdentical('public://image-1.png', $file->getFileUri());
     $this->assertIdentical('image/png', $file->getMimeType());
     // It is pointless to run the second half from MigrateDrupal6Test.
     if (empty($this->standalone)) {
         return;
     }
     // Test that we can re-import and also test with file_directory_path set.
     db_truncate(entity_load('migration', 'd6_file')->getIdMap()->mapTableName())->execute();
     $migration = entity_load_unchanged('migration', 'd6_file');
     $dumps = array($this->getDumpDirectory() . '/Variable.php');
     $this->prepare($migration, $dumps);
     // Update the file_directory_path.
     Database::getConnection('default', 'migrate')->update('variable')->fields(array('value' => serialize('files/test')))->condition('name', 'file_directory_path')->execute();
     Database::getConnection('default', 'migrate')->update('variable')->fields(array('value' => serialize($this->getTempFilesDirectory())))->condition('name', 'file_directory_temp')->execute();
     $executable = new MigrateExecutable($migration, $this);
     $executable->import();
     $file = entity_load('file', 2);
     $this->assertIdentical('public://core/modules/simpletest/files/image-2.jpg', $file->getFileUri());
     // Ensure that a temporary file has been migrated.
     $file = entity_load('file', 6);
     $this->assertIdentical('temporary://' . static::getUniqueFilename(), $file->getFileUri());
 }
开发者ID:dev981,项目名称:gaptest,代码行数:31,代码来源:MigrateFileTest.php

示例3: testForm

 /**
  * Tests the form.
  */
 function testForm()
 {
     $user = $this->drupalCreateUser(array('currency.currency_locale.delete'));
     $this->drupalLogin($user);
     $currency_locale = entity_create('currency_locale', array('locale' => 'zz_ZZ'));
     $currency_locale->save();
     $this->drupalPostForm('admin/config/regional/currency-formatting/locale/' . $currency_locale->id() . '/delete', array(), t('Delete'));
     $this->assertFalse(entity_load_unchanged('currency_locale', $currency_locale->id()));
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:12,代码来源:CurrencyLocaleDeleteFormWebTest.php

示例4: testForm

 /**
  * Tests the form.
  */
 function testForm()
 {
     $user = $this->drupalCreateUser(array('currency.currency.delete'));
     $this->drupalLogin($user);
     $currency = entity_create('currency', array('currencyCode' => 'ABC'));
     $currency->save();
     $this->drupalPostForm('admin/config/regional/currency/' . $currency->id() . '/delete', array(), t('Delete'));
     $this->assertFalse((bool) entity_load_unchanged('currency', $currency->id()));
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:12,代码来源:CurrencyDeleteFormWebTest.php

示例5: testEntityOriginal

 /**
  * Test the [entity:original:*] tokens.
  */
 function testEntityOriginal()
 {
     $node = Node::create(['type' => 'page', 'title' => 'Original title']);
     $node->save();
     $tokens = array('nid' => $node->id(), 'title' => 'Original title', 'original' => NULL, 'original:nid' => NULL);
     $this->assertTokens('node', array('node' => $node), $tokens);
     // Emulate the original entity property that would be available from
     // node_save() and change the title for the node.
     $node->original = entity_load_unchanged('node', $node->id());
     $node->title = 'New title';
     $tokens = array('nid' => $node->id(), 'title' => 'New title', 'original' => 'Original title', 'original:nid' => $node->id());
     $this->assertTokens('node', array('node' => $node), $tokens);
 }
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:16,代码来源:EntityTest.php

示例6: testMenu

 /**
  * Tests the Drupal 6 menu to Drupal 8 migration.
  */
 public function testMenu()
 {
     $navigation_menu = entity_load('menu', 'navigation');
     $this->assertEqual($navigation_menu->id(), 'navigation');
     $this->assertEqual($navigation_menu->label(), 'Navigation');
     $this->assertEqual($navigation_menu->description, 'The navigation menu is provided by Drupal and is the main interactive menu for any site. It is usually the only menu that contains personalized links for authenticated users, and is often not even visible to anonymous users.');
     // Test that we can re-import using the ConfigEntityBase destination.
     Database::getConnection('default', 'migrate')->update('menu_custom')->fields(array('title' => 'Home Navigation'))->condition('menu_name', 'navigation')->execute();
     db_truncate(entity_load('migration', 'd6_menu')->getIdMap()->mapTableName())->execute();
     $migration = entity_load_unchanged('migration', 'd6_menu');
     $executable = new MigrateExecutable($migration, $this);
     $executable->import();
     $navigation_menu = entity_load_unchanged('menu', 'navigation');
     $this->assertEqual($navigation_menu->label(), 'Home Navigation');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:18,代码来源:MigrateMenuTest.php

示例7: getOriginalEntity

 /**
  * Get original entity
  *
  * @return EntityInterface
  */
 public function getOriginalEntity()
 {
     $entity = $this->getEntity();
     if ($entity->isNew()) {
         throw new \LogicException(sprintf('entity is new for event %s', $this->getEventName()));
     }
     if (isset($entity->original)) {
         return $entity->original;
     }
     // No entity, attempt original entity load
     $original = entity_load_unchanged($this->getEntityType(), $this->getEntityId());
     if ($original) {
         return $original;
     }
     throw new \LogicException(sprintf('there is no original entity for event %s', $this->getEventName()));
 }
开发者ID:makinacorpus,项目名称:drupal-sf-dic,代码行数:21,代码来源:EntityEvent.php

示例8: testField

 /**
  * Tests the field.
  */
 protected function testField()
 {
     // Create the field and field instance.
     $field_name = strtolower($this->randomMachineName());
     entity_create('field_storage_config', ['cardinality' => FieldStorageConfigInterface::CARDINALITY_UNLIMITED, 'entity_type' => 'user', 'field_name' => $field_name, 'type' => 'payment_form'])->save();
     entity_create('field_config', ['bundle' => 'user', 'entity_type' => 'user', 'field_name' => $field_name, 'settings' => ['currency_code' => 'EUR']])->save();
     // Set a field value on an entity and test getting it.
     $user = entity_create('user', ['name' => $this->randomString()]);
     foreach (Generate::createPaymentLineItems() as $line_item) {
         $user->get($field_name)->appendItem(['plugin_id' => $line_item->getPluginId(), 'plugin_configuration' => $line_item->getConfiguration()]);
     }
     $this->assertFieldValue($user, $field_name);
     // Save the entity, load it from storage and test getting the field value.
     $user->save();
     $user = entity_load_unchanged('user', $user->id());
     $this->assertFieldValue($user, $field_name);
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:20,代码来源:PaymentFormWebTest.php

示例9: testDateFormats

 /**
  * Tests the Drupal 6 date formats to Drupal 8 migration.
  */
 public function testDateFormats()
 {
     $short_date_format = entity_load('date_format', 'short');
     $this->assertIdentical('\\S\\H\\O\\R\\T m/d/Y - H:i', $short_date_format->getPattern());
     $medium_date_format = entity_load('date_format', 'medium');
     $this->assertIdentical('\\M\\E\\D\\I\\U\\M D, m/d/Y - H:i', $medium_date_format->getPattern());
     $long_date_format = entity_load('date_format', 'long');
     $this->assertIdentical('\\L\\O\\N\\G l, F j, Y - H:i', $long_date_format->getPattern());
     // Test that we can re-import using the EntityDateFormat destination.
     Database::getConnection('default', 'migrate')->update('variable')->fields(array('value' => serialize('\\S\\H\\O\\R\\T d/m/Y - H:i')))->condition('name', 'date_format_short')->execute();
     db_truncate(entity_load('migration', 'd6_date_formats')->getIdMap()->mapTableName())->execute();
     $migration = entity_load_unchanged('migration', 'd6_date_formats');
     $executable = new MigrateExecutable($migration, $this);
     $executable->import();
     $short_date_format = entity_load('date_format', 'short');
     $this->assertIdentical('\\S\\H\\O\\R\\T d/m/Y - H:i', $short_date_format->getPattern());
 }
开发者ID:scratch,项目名称:gai,代码行数:20,代码来源:MigrateDateFormatTest.php

示例10: testSearchPage

 /**
  * Tests Drupal 6 search settings to Drupal 8 search page entity migration.
  */
 public function testSearchPage()
 {
     $id = 'node_search';
     /** @var \Drupal\search\Entity\SearchPage $search_page */
     $search_page = entity_load('search_page', $id);
     $this->assertIdentical($id, $search_page->id());
     $configuration = $search_page->getPlugin()->getConfiguration();
     $this->assertIdentical($configuration['rankings'], array('comments' => 5, 'relevance' => 2, 'sticky' => 8, 'views' => 1));
     $this->assertIdentical('node', $search_page->getPath());
     // Test that we can re-import using the EntitySearchPage destination.
     Database::getConnection('default', 'migrate')->update('variable')->fields(array('value' => serialize(4)))->condition('name', 'node_rank_comments')->execute();
     $migration = entity_load_unchanged('migration', 'd6_search_page');
     $executable = new MigrateExecutable($migration, $this);
     $executable->import();
     $search_page = entity_load('search_page', $id);
     $configuration = $search_page->getPlugin()->getConfiguration();
     $this->assertIdentical(4, $configuration['rankings']['comments']);
 }
开发者ID:dev981,项目名称:gaptest,代码行数:21,代码来源:MigrateSearchPageTest.php

示例11: testCRUD

 /**
  * Tests CRUD();
  */
 protected function testCRUD()
 {
     $database = \Drupal::database();
     $user = $this->drupalCreateUser();
     $payment_type_configuration = array($this->randomMachineName() => $this->randomMachineName());
     $payment_method = Payment::methodManager()->createInstance('payment_basic:no_payment_required');
     // Test creating a payment.
     $payment = Generate::createPayment($user->id(), $payment_method);
     $payment->getPaymentType()->setConfiguration($payment_type_configuration);
     $this->assertTrue($payment instanceof PaymentInterface);
     // @todo The ID should be an integer, but for some reason the entity field
     //   API returns a string.
     $this->assertTrue(is_numeric($payment->getOwnerId()));
     $this->assertEqual(count($payment->validate()), 0);
     $this->assertTrue($payment->getPaymentType() instanceof PaymentTypeInterface);
     // Test saving a payment.
     $this->assertFalse($payment->id());
     // Set an extra status, so we can test for status IDs later.
     $payment->setPaymentStatus(Payment::statusManager()->createInstance('payment_success'));
     $payment->save();
     // @todo The ID should be an integer, but for some reason the entity field
     //   API returns a string.
     $this->assertTrue(is_numeric($payment->id()));
     $this->assertTrue(strlen($payment->uuid()));
     // @todo The ID should be an integer, but for some reason the entity field
     //   API returns a string.
     $this->assertTrue(is_numeric($payment->getOwnerId()));
     // Check references to other tables.
     $payment_data = $database->select('payment', 'p')->fields('p', array('current_payment_status_delta'))->condition('id', $payment->id())->execute()->fetchAssoc();
     $this->assertEqual($payment_data['current_payment_status_delta'], 1);
     /** @var \Drupal\payment\Entity\PaymentInterface $payment_loaded */
     $payment_loaded = entity_load_unchanged('payment', $payment->id());
     $this->assertEqual(count($payment_loaded->getLineItems()), count($payment->getLineItems()));
     foreach ($payment_loaded->getLineItems() as $line_item) {
         $this->assertTrue($line_item instanceof PaymentLineItemInterface);
     }
     $this->assertEqual(count($payment_loaded->getPaymentStatuses()), count($payment->getPaymentStatuses()));
     foreach ($payment_loaded->getPaymentStatuses() as $status) {
         $this->assertTrue($status instanceof PaymentStatusInterface);
     }
     $this->assertEqual($payment_loaded->getPaymentMethod()->getConfiguration(), $payment->getPaymentMethod()->getConfiguration());
     $this->assertEqual($payment_loaded->getPaymentType()->getConfiguration(), $payment->getPaymentType()->getConfiguration());
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:46,代码来源:PaymentStorageWebTest.php

示例12: testUrlAlias

 /**
  * Test the url alias migration.
  */
 public function testUrlAlias()
 {
     $migration = entity_load('migration', 'd6_url_alias');
     // Test that the field exists.
     $conditions = array('source' => '/node/1', 'alias' => '/alias-one', 'langcode' => 'en');
     $path = \Drupal::service('path.alias_storage')->load($conditions);
     $this->assertNotNull($path, "Path alias for node/1 successfully loaded.");
     $this->assertIdentical($migration->getIdMap()->lookupDestinationID(array($path['pid'])), array('1'), "Test IdMap");
     $conditions = array('source' => '/node/2', 'alias' => '/alias-two', 'langcode' => 'en');
     $path = \Drupal::service('path.alias_storage')->load($conditions);
     $this->assertNotNull($path, "Path alias for node/2 successfully loaded.");
     // Test that we can re-import using the UrlAlias destination.
     Database::getConnection('default', 'migrate')->update('url_alias')->fields(array('dst' => 'new-url-alias'))->condition('src', 'node/2')->execute();
     db_update($migration->getIdMap()->mapTableName())->fields(array('source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE))->execute();
     $migration = entity_load_unchanged('migration', 'd6_url_alias');
     $executable = new MigrateExecutable($migration, $this);
     $executable->import();
     $path = \Drupal::service('path.alias_storage')->load(array('pid' => $path['pid']));
     $this->assertIdentical('/new-url-alias', $path['alias']);
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:23,代码来源:MigrateUrlAliasTest.php

示例13: doTestEnableDisable

 /**
  * Tests enabling/disabling.
  */
 protected function doTestEnableDisable()
 {
     $this->drupalLogout();
     // Confirm that there are no enable/disable links without the required
     // permissions.
     $this->drupalLogin($this->drupalCreateUser(array('payment.payment_method_configuration.view.any')));
     $this->drupalGet('admin/config/services/payment/method/configuration');
     $this->assertNoLink(t('Enable'));
     $this->assertNoLink(t('Disable'));
     /** @var \Drupal\payment\Entity\PaymentMethodConfigurationInterface $payment_method */
     $payment_method = entity_load('payment_method_configuration', 'collect_on_delivery');
     $this->assertFalse($payment_method->status());
     $this->drupalLogin($this->drupalCreateUser(array('payment.payment_method_configuration.view.any', 'payment.payment_method_configuration.update.any')));
     $this->drupalGet('admin/config/services/payment/method/configuration');
     $this->clickLink(t('Enable'));
     $payment_method = entity_load_unchanged('payment_method_configuration', 'collect_on_delivery');
     $this->assertTrue($payment_method->status());
     $this->clickLink(t('Disable'));
     $payment_method = entity_load_unchanged('payment_method_configuration', 'collect_on_delivery');
     $this->assertFalse($payment_method->status());
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:24,代码来源:PaymentMethodWebTest.php

示例14: testField

 /**
  * Tests the field.
  */
 protected function testField()
 {
     // Create the field and field instance.
     $field_name = strtolower($this->randomMachineName());
     entity_create('field_storage_config', array('cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, 'entity_type' => 'user', 'field_name' => $field_name, 'type' => 'payment_reference'))->save();
     entity_create('field_config', array('bundle' => 'user', 'entity_type' => 'user', 'field_name' => $field_name, 'settings' => array('currency_code' => 'EUR', 'line_items_data' => [])))->save();
     $payment = Generate::createPayment(mt_rand());
     $payment->setPaymentStatus(Payment::statusManager()->createInstance('payment_success'));
     $payment->save();
     PaymentReference::queue()->save('user.' . $field_name, $payment->id());
     $this->assertEqual(PaymentReference::queue()->loadPaymentIds('user.' . $field_name, $payment->getOwnerId()), array($payment->id()));
     // Set a field value on an entity and test getting it.
     /** @var \Drupal\user\UserInterface $user */
     $user = entity_create('user', array('name' => $this->randomString()));
     $user->get($field_name)->appendItem($payment->id());
     $this->assertEqual($user->get($field_name)->first()->entity->id(), $payment->id());
     // Save the entity, load it from storage and test getting the field value.
     $user->save();
     $user = entity_load_unchanged('user', $user->id());
     $this->assertEqual($user->{$field_name}[0]->target_id, $payment->id());
     $this->assertEqual(PaymentReference::queue()->loadPaymentIds('user.' . $field_name, $payment->getOwnerId()), []);
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:25,代码来源:PaymentReferenceWebTest.php

示例15: testFiles

 /**
  * Tests the Drupal 6 files to Drupal 8 migration.
  */
 public function testFiles()
 {
     /** @var \Drupal\file\FileInterface $file */
     $file = entity_load('file', 1);
     $this->assertEqual($file->getFilename(), 'Image1.png');
     $this->assertEqual($file->getSize(), 39325);
     $this->assertEqual($file->getFileUri(), 'public://image-1.png');
     $this->assertEqual($file->getMimeType(), 'image/png');
     // It is pointless to run the second half from MigrateDrupal6Test.
     if (empty($this->standalone)) {
         return;
     }
     // Test that we can re-import and also test with file_directory_path set.
     db_truncate(entity_load('migration', 'd6_file')->getIdMap()->mapTableName())->execute();
     $migration = entity_load_unchanged('migration', 'd6_file');
     $dumps = array($this->getDumpDirectory() . '/Drupal6SystemFile.php');
     $this->loadDumps($dumps, 'loadMigrateFileStandalone');
     $executable = new MigrateExecutable($migration, $this);
     $executable->import();
     $file = entity_load('file', 2);
     $this->assertEqual($file->getFileUri(), 'public://core/modules/simpletest/files/image-2.jpg');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:25,代码来源:MigrateFileTest.php


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