• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP entity_load_unchanged函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: save

 /**
  * Overrides Entity::save().
  *
  * Maintains the role, adding or removing it from the owner when necessary.
  */
 public function save()
 {
     if ($this->uid && $this->product_id) {
         $role = $this->wrapper->product->commerce_license_role->value();
         $owner = $this->wrapper->owner->value();
         $save_owner = FALSE;
         if (!empty($this->license_id)) {
             $this->original = entity_load_unchanged('commerce_license', $this->license_id);
             // A plan change occurred. Remove the previous role.
             if ($this->original->product_id && $this->product_id != $this->original->product_id) {
                 $previous_role = $this->original->wrapper->product->commerce_license_role->value();
                 if (isset($owner->roles[$previous_role])) {
                     unset($owner->roles[$previous_role]);
                     $save_owner = TRUE;
                 }
             }
         }
         // The owner of an active license must have the role.
         if ($this->status == COMMERCE_LICENSE_ACTIVE) {
             if (!isset($owner->roles[$role])) {
                 $owner->roles[$role] = $role;
                 $save_owner = TRUE;
             }
         } elseif ($this->status > COMMERCE_LICENSE_ACTIVE) {
             // The owner of an inactive license must not have the role.
             if (isset($owner->roles[$role])) {
                 unset($owner->roles[$role]);
                 $save_owner = TRUE;
             }
         }
         // If a role was added or removed, save the owner.
         if ($save_owner) {
             user_save($owner);
         }
     }
     parent::save();
 }
开发者ID:chelsiejohnston,项目名称:stevesstage,代码行数:42,代码来源:CommerceLicenseRole.class.php


示例17: api_node_save

function api_node_save($node)
{
    $transaction = db_transaction();
    try {
        // Load the stored entity, if any.
        if (!empty($node->nid) && !isset($node->original)) {
            $node->original = entity_load_unchanged('node', $node->nid);
        }
        field_attach_presave('node', $node);
        global $user;
        // Determine if we will be inserting a new node.
        if (!isset($node->is_new)) {
            $node->is_new = empty($node->nid);
        }
        /*
            // Set the timestamp fields.
            if (empty($node->created)) {
              $node->created = REQUEST_TIME;
            }
            // The changed timestamp is always updated for bookkeeping purposes,
            // for example: revisions, searching, etc.
            $node->changed = REQUEST_TIME;
        
            $node->timestamp = REQUEST_TIME;
        */
        $update_node = TRUE;
        // Let modules modify the node before it is saved to the database.
        module_invoke_all('node_presave', $node);
        module_invoke_all('entity_presave', $node, 'node');
        if ($node->is_new || !empty($node->revision)) {
            // When inserting either a new node or a new node revision, $node->log
            // must be set because {node_revision}.log is a text column and therefore
            // cannot have a default value. However, it might not be set at this
            // point (for example, if the user submitting a node form does not have
            // permission to create revisions), so we ensure that it is at least an
            // empty string in that case.
            // @todo: Make the {node_revision}.log column nullable so that we can
            // remove this check.
            if (!isset($node->log)) {
                $node->log = '';
            }
        } elseif (!isset($node->log) || $node->log === '') {
            // If we are updating an existing node without adding a new revision, we
            // need to make sure $node->log is unset whenever it is empty. As long as
            // $node->log is unset, drupal_write_record() will not attempt to update
            // the existing database column when re-saving the revision; therefore,
            // this code allows us to avoid clobbering an existing log entry with an
            // empty one.
            unset($node->log);
        }
        // When saving a new node revision, unset any existing $node->vid so as to
        // ensure that a new revision will actually be created, then store the old
        // revision ID in a separate property for use by node hook implementations.
        if (!$node->is_new && !empty($node->revision) && $node->vid) {
            $node->old_vid = $node->vid;
            unset($node->vid);
        }
        // Save the node and node revision.
        if ($node->is_new) {
            // For new nodes, save new records for both the node itself and the node
            // revision.
            drupal_write_record('node', $node);
            _node_save_revision($node, $user->uid);
            $op = 'insert';
        } else {
            // For existing nodes, update the node record which matches the value of
            // $node->nid.
            drupal_write_record('node', $node, 'nid');
            // Then, if a new node revision was requested, save a new record for
            // that; otherwise, update the node revision record which matches the
            // value of $node->vid.
            if (!empty($node->revision)) {
                _node_save_revision($node, $user->uid);
            } else {
                _node_save_revision($node, $user->uid, 'vid');
                $update_node = FALSE;
            }
            $op = 'update';
        }
        if ($update_node) {
            db_update('node')->fields(array('vid' => $node->vid))->condition('nid', $node->nid)->execute();
        }
        // Call the node specific callback (if any). This can be
        // node_invoke($node, 'insert') or
        // node_invoke($node, 'update').
        node_invoke($node, $op);
        // Save fields.
        $function = "field_attach_{$op}";
        $function('node', $node);
        module_invoke_all('node_' . $op, $node);
        module_invoke_all('entity_' . $op, $node, 'node');
        // Update the node access table for this node.
        node_access_acquire_grants($node);
        // Clear internal properties.
        unset($node->is_new);
        unset($node->original);
        // Clear the static loading cache.
        entity_get_controller('node')->resetCache(array($node->nid));
        // Ignore slave server temporarily to give time for the
        // saved node to be propagated to the slave.
//.........这里部分代码省略.........
开发者ID:sanjay9267,项目名称:dnaindia,代码行数:101,代码来源:topic_cron.php


示例18: testCheckoutForm

 /**
  * Test the page callbacks to create jobs and check them out.
  *
  * This includes
  * - Varying checkout situations with form detail values.
  * - Unsupported checkout situations where translator is not available.
  * - Exposed filters for job overview
  * - Deleting a job
  *
  * @todo Separate the exposed filter admin overview test.
  */
 function testCheckoutForm()
 {
     // Add a first item to the job. This will auto-create the job.
     $job = tmgmt_job_match_item('en', '');
     $job->addItem('test_source', 'test', 1);
     // Go to checkout form.
     $redirects = tmgmt_job_checkout_multiple(array($job));
     $this->drupalGet(reset($redirects));
     // Test primary buttons.
     $this->assertRaw('Save job" class="button js-form-submit form-submit"');
     // Check checkout form.
     $this->assertText('test_source:test:1');
     // Add two more job items.
     $job->addItem('test_source', 'test', 2);
     $job->addItem('test_source', 'test', 3);
     // Go to checkout form.
     $redirects = tmgmt_job_checkout_multiple(array($job));
     $this->drupalGet(reset($redirects));
     // Check checkout form.
     $this->assertText('test_source:test:1');
     $this->assertText('test_source:test:2');
     $this->assertText('test_source:test:3');
     // @todo: Test ajax functionality.
     // Attempt to translate into greek.
     $edit = array('target_language' => 'el', 'settings[action]' => 'translate');
     $this->drupalPostForm(NULL, $edit, t('Submit to provider'));
     $this->assertText(t('@translator can not translate from @source to @target.', array('@translator' => 'Test provider', '@source' => 'English', '@target' => 'Greek')));
     // Job still needs to be in state new.
     /** @var \Drupal\tmgmt\JobInterface $job */
     $job = \Drupal::entityTypeManager()->getStorage('tmgmt_job')->loadUnchanged($job->id());
     $this->assertTrue($job->isUnprocessed());
     // The owner must be the one that submits the job.
     $this->assertTrue($job->isAuthor());
     $this->drupalLogin($this->translator_user);
     $this->drupalGet('admin/tmgmt/jobs/' . $job->id());
     $edit = array('target_language' => 'es', 'settings[action]' => 'translate');
     $this->drupalPostForm(NULL, $edit, t('Submit to provider'));
     /** @var \Drupal\tmgmt\JobInterface $job */
     $job = \Drupal::entityTypeManager()->getStorage('tmgmt_job')->loadUnchanged($job->id());
     $this->assertTrue($job->isAuthor());
     // Job needs to be in state active.
     $job = \Drupal::entityTypeManager()->getStorage('tmgmt_job')->loadUnchanged($job->id());
     $this->assertTrue($job->isActive());
     foreach ($job->getItems() as $job_item) {
         /* @var $job_item \Drupal\tmgmt\JobItemInterface */
         $this->assertTrue($job_item->isNeedsReview());
     }
     $this->assertText(t('Test translation created'));
     $this->assertNoText(t('Test provider called'));
     // Test redirection.
     $this->assertText(t('Job overview'));
     // Another job.
     $previous_tjid = $job->id();
     $job = tmgmt_job_match_item('en', '');
     $job->addItem('test_source', 'test', 9);
     $this->assertNotEqual($job->id(), $previous_tjid);
     // Go to checkout form.
     $redirects = tmgmt_job_checkout_multiple(array($job));
     $this->drupalGet(reset($redirects));
     // Check checkout form.
     $this->assertText('You can provide a label for this job in order to identify it easily later on.');
     $this->assertText('test_source:test:9');
     $edit = array('target_language' => 'es', 'settings[action]' => 'submit');
     $this->drupalPostForm(NULL, $edit, t('Submit to provider'));
     $this->assertText(t('Test submit'));
     $job = entity_load_unchanged('tmgmt_job', $job->id());
     $this->assertTrue($job->isActive());
     // Another job.
     $job = tmgmt_job_match_item('en', 'es');
     $job->addItem('test_source', 'test', 10);
     // Go to checkout form.
     $redirects = tmgmt_job_checkout_multiple(array($job));
     $this->drupalGet(reset($redirects));
     // Check checkout form.
     $this->assertText('You can provide a label for this job in order to identify it easily later on.');
     $this->assertText('test_source:test:10');
     $edit = array('settings[action]' => 'reject');
     $this->drupalPostForm(NULL, $edit, t('Submit to provider'));
     $this->assertText(t('This is not supported'));
     $job = entity_load_unchanged('tmgmt_job', $job->id());
     $this->assertTrue($job->isRejected());
     // Check displayed job messages.
     $args = array('@view' => 'view-tmgmt-job-messages');
     $this->assertEqual(2, count($this->xpath('//div[contains(@class, @view)]//tbody/tr', $args)));
     // Check that the author for each is the current user.
     $message_authors = $this->xpath('////div[contains(@class, @view)]//td[contains(@class, @field)]/span', $args + array('@field' => 'views-field-name'));
     $this->assertEqual(2, count($message_authors));
     foreach ($message_authors as $message_author) {
         $this->assertEqual((string) $message_author, $this->translator_user->getUsername());
//.........这里部分代码省略.........
开发者ID:andrewl,项目名称:andrewlnet,代码行数:101,代码来源:TMGMTUiTest.php


示例19: testPaymentUi

 /**
  * Tests the payment UI.
  */
 protected function testPaymentUi()
 {
     $this->drupalPlaceBlock('local_tasks_block');
     $payment_method = Payment::methodManager()->createInstance('payment_test');
     // Create just enough payments for three pages
     $count_payments = 50 * 2 + 1;
     foreach (range(0, $count_payments) as $i) {
         $payment = Generate::createPayment(2, $payment_method);
         $payment->save();
         $payment = entity_load_unchanged('payment', $payment->id());
     }
     // View the administrative listing.
     $this->drupalLogin($this->drupalCreateUser(array('access administration pages')));
     $this->drupalGet('admin/content');
     $this->assertResponse('200');
     $this->assertNoLinkByHref('admin/content/payment');
     $this->drupalGet('admin/content/payment');
     $this->assertResponse('403');
     $this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'payment.payment.view.any')));
     $this->drupalGet('admin/content');
     $this->clickLink(t('Payments'));
     if ($this->assertResponse('200')) {
         $this->assertTitle(t('Payments | Drupal'));
         $this->assertText(t('Last updated'));
         $this->assertText(t('Payment method'));
         $this->assertText(t('Enter a comma separated list of user names.'));
         $this->assertText(t('EUR 24.20'));
         $this->assertText($payment_method->getPluginLabel());
         $count_pages = ceil($count_payments / 50);
         if ($count_pages) {
             foreach (range(1, $count_pages - 1) as $page) {
                 $this->assertLinkByHref('&page=' . $page);
             }
             $this->assertNoLinkByHref('&page=' . ($page + 1));
         }
         $this->assertLinkByHref('payment/1');
         $this->clickLinkPartialName('Next');
         $this->assertUrl('admin/content/payment?changed_after=&changed_before=&=Apply&page=1');
     }
     $this->drupalLogout();
     // View the payment.
     $path = 'payment/' . $payment->id();
     $this->drupalGet($path);
     $this->assertResponse('403');
     $this->drupalLogin($this->drupalCreateUser(array('payment.payment.view.any')));
     $this->drupalGet($path);
     if ($this->assertResponse('200')) {
         $this->assertText(t('Payment method'));
         $this->assertText(t('Status'));
     }
     // Delete a payment.
     $path = 'payment/' . $payment->id() . '/delete';
     $this->drupalGet($path);
     $this->assertResponse('403');
     $this->drupalLogin($this->drupalCreateUser(array('payment.payment.delete.any', 'payment.payment.view.any')));
     $this->drupalGet($path);
     if ($this->assertResponse('200')) {
         $this->clickLink(t('Cancel'));
         $this->assertUrl('payment/' . $payment->id());
         $this->drupalGet($path);
         $this->drupalPostForm(NULL, [], t('Delete'));
         $this->assertResponse('200');
         $this->assertFalse((bool) \Drupal::entityManager()->getStorage('payment')->loadUnchanged($payment->id()));
     }
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:68,代码来源:PaymentWebTest.php


示例20: saveCard

 /**
  * Save a card on file object
  */
 public function saveCard($card, $billing_profile = NULL, $new_values = array())
 {
     // Remove metadata values
     if (!empty($new_values)) {
         unset($new_values['no_store']);
     }
     // If new card ...
     if (empty($card->card_id)) {
         if (!empty($new_values)) {
             foreach ($new_values as $prop => $new_value) {
                 $card->{$prop} = $new_value;
             }
 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP entity_metadata_wrapper函数代码示例发布时间:2022-05-15
下一篇:
PHP entity_load_single函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap