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

PHP entity_load_multiple函数代码示例

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

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



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

示例1: testTaxonomyTermMultipleLoad

 /**
  * Create a vocabulary and some taxonomy terms, ensuring they're loaded
  * correctly using entity_load_multiple().
  */
 function testTaxonomyTermMultipleLoad()
 {
     // Create a vocabulary.
     $vocabulary = $this->createVocabulary();
     // Create five terms in the vocabulary.
     $i = 0;
     while ($i < 5) {
         $i++;
         $this->createTerm($vocabulary);
     }
     // Load the terms from the vocabulary.
     $terms = entity_load_multiple_by_properties('taxonomy_term', array('vid' => $vocabulary->id()));
     $count = count($terms);
     $this->assertEqual($count, 5, format_string('Correct number of terms were loaded. !count terms.', array('!count' => $count)));
     // Load the same terms again by tid.
     $terms2 = entity_load_multiple('taxonomy_term', array_keys($terms));
     $this->assertEqual($count, count($terms2), 'Five terms were loaded by tid.');
     $this->assertEqual($terms, $terms2, 'Both arrays contain the same terms.');
     // Remove one term from the array, then delete it.
     $deleted = array_shift($terms2);
     $deleted->delete();
     $deleted_term = entity_load('taxonomy_term', $deleted->id());
     $this->assertFalse($deleted_term);
     // Load terms from the vocabulary by vid.
     $terms3 = entity_load_multiple_by_properties('taxonomy_term', array('vid' => $vocabulary->id()));
     $this->assertEqual(count($terms3), 4, 'Correct number of terms were loaded.');
     $this->assertFalse(isset($terms3[$deleted->id()]));
     // Create a single term and load it by name.
     $term = $this->createTerm($vocabulary);
     $loaded_terms = entity_load_multiple_by_properties('taxonomy_term', array('name' => $term->getName()));
     $this->assertEqual(count($loaded_terms), 1, 'One term was loaded.');
     $loaded_term = reset($loaded_terms);
     $this->assertEqual($term->id(), $loaded_term->id(), 'Term loaded by name successfully.');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:38,代码来源:LoadMultipleTest.php


示例2: settingsForm

 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor)
 {
     $settings = $editor->getSettings();
     $medium_editors = array();
     foreach (entity_load_multiple('medium_editor') as $medium_editor) {
         $medium_editors[$medium_editor->id()] = $medium_editor->label();
     }
     // Default editor
     $form['default_editor'] = array('#type' => 'select', '#title' => $this->t('Medium Editor'), '#options' => $medium_editors, '#default_value' => $settings['default_editor'], '#description' => $this->t('Select the default editor for the authorized roles. Editors can be configured at <a href="!url">Medium admin page</a>.', array('!url' => \Drupal::url('medium.admin'))), '#empty_option' => '- ' . $this->t('Select an editor') . ' -');
     // Roles editors
     $role_ids = array();
     if ($format_form = $form_state->getCompleteForm()) {
         if (isset($format_form['roles']['#value'])) {
             $role_ids = $format_form['roles']['#value'];
         } elseif (isset($format_form['roles']['#default_value'])) {
             $role_ids = $format_form['roles']['#default_value'];
         }
     } elseif ($format = $editor->getFilterFormat()) {
         $role_ids = array_keys(filter_get_roles_by_format($format));
     }
     if (count($role_ids) > 1) {
         $form['roles_editors'] = array('#type' => 'details', '#title' => t('Role specific editors'));
         $roles = user_roles();
         foreach ($role_ids as $role_id) {
             $form['roles_editors'][$role_id] = array('#type' => 'select', '#title' => $this->t('Editor for %role', array('%role' => $roles[$role_id]->label())), '#options' => $medium_editors, '#default_value' => isset($settings['roles_editors'][$role_id]) ? $settings['roles_editors'][$role_id] : '', '#empty_option' => '- ' . $this->t('Use the default') . ' -');
         }
     }
     return $form;
 }
开发者ID:digideskio,项目名称:medium-editor-d8,代码行数:32,代码来源:MediumEditor.php


示例3: preRender

 public function preRender(&$values)
 {
     $vocabularies = entity_load_multiple('taxonomy_vocabulary');
     $this->field_alias = $this->aliases['nid'];
     $nids = array();
     foreach ($values as $result) {
         if (!empty($result->{$this->aliases['nid']})) {
             $nids[] = $result->{$this->aliases['nid']};
         }
     }
     if ($nids) {
         $vocabs = array_filter($this->options['vids']);
         if (empty($this->options['limit'])) {
             $vocabs = array();
         }
         $result = \Drupal::entityManager()->getStorage('taxonomy_term')->getNodeTerms($nids, $vocabs);
         foreach ($result as $node_nid => $data) {
             foreach ($data as $tid => $term) {
                 $this->items[$node_nid][$tid]['name'] = \Drupal::entityManager()->getTranslationFromContext($term)->label();
                 $this->items[$node_nid][$tid]['tid'] = $tid;
                 $this->items[$node_nid][$tid]['vocabulary_vid'] = $term->getVocabularyId();
                 $this->items[$node_nid][$tid]['vocabulary'] = String::checkPlain($vocabularies[$term->getVocabularyId()]->label());
                 if (!empty($this->options['link_to_taxonomy'])) {
                     $this->items[$node_nid][$tid]['make_link'] = TRUE;
                     $this->items[$node_nid][$tid]['path'] = 'taxonomy/term/' . $tid;
                 }
             }
         }
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:30,代码来源:TaxonomyIndexTid.php


示例4: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     entity_create('field_storage_config', array('entity_type' => 'node', 'field_name' => 'field_test', 'type' => 'text'))->save();
     entity_create('field_config', array('entity_type' => 'node', 'field_name' => 'field_test', 'bundle' => 'story'))->save();
     entity_create('field_storage_config', array('entity_type' => 'node', 'field_name' => 'field_test_two', 'type' => 'integer', 'cardinality' => -1))->save();
     entity_create('field_config', array('entity_type' => 'node', 'field_name' => 'field_test_two', 'bundle' => 'story'))->save();
     entity_create('field_storage_config', array('entity_type' => 'node', 'field_name' => 'field_test_three', 'type' => 'decimal'))->save();
     entity_create('field_config', array('entity_type' => 'node', 'field_name' => 'field_test_three', 'bundle' => 'story'))->save();
     entity_create('field_storage_config', array('entity_type' => 'node', 'field_name' => 'field_test_integer_selectlist', 'type' => 'integer'))->save();
     entity_create('field_config', array('entity_type' => 'node', 'field_name' => 'field_test_integer_selectlist', 'bundle' => 'story'))->save();
     entity_create('field_storage_config', array('entity_type' => 'node', 'field_name' => 'field_test_exclude_unset', 'type' => 'text'))->save();
     entity_create('field_config', array('entity_type' => 'node', 'field_name' => 'field_test_exclude_unset', 'bundle' => 'story'))->save();
     entity_create('field_storage_config', array('entity_type' => 'node', 'field_name' => 'field_multivalue', 'type' => 'decimal', 'precision' => '10', 'scale' => '2', 'cardinality' => -1))->save();
     entity_create('field_config', array('entity_type' => 'node', 'field_name' => 'field_multivalue', 'bundle' => 'test_planet'))->save();
     entity_create('field_storage_config', array('entity_type' => 'node', 'field_name' => 'field_test_identical1', 'type' => 'integer'))->save();
     entity_create('field_config', array('entity_type' => 'node', 'field_name' => 'field_test_identical1', 'bundle' => 'story'))->save();
     entity_create('field_storage_config', array('entity_type' => 'node', 'field_name' => 'field_test_identical2', 'type' => 'integer'))->save();
     entity_create('field_config', array('entity_type' => 'node', 'field_name' => 'field_test_identical2', 'bundle' => 'story'))->save();
     entity_create('field_storage_config', array('entity_type' => 'node', 'field_name' => 'field_test_link', 'type' => 'link'))->save();
     entity_create('field_config', array('entity_type' => 'node', 'field_name' => 'field_test_link', 'bundle' => 'story'))->save();
     entity_create('field_storage_config', array('entity_type' => 'node', 'field_name' => 'field_test_filefield', 'type' => 'file'))->save();
     entity_create('field_config', array('entity_type' => 'node', 'field_name' => 'field_test_filefield', 'bundle' => 'story'))->save();
     // Add some id mappings for the dependant migrations.
     $id_mappings = array('d6_field_formatter_settings' => array(array(array('page', 'default', 'node', 'field_test'), array('node', 'page', 'default', 'field_test'))), 'd6_field_instance_widget_settings' => array(array(array('page', 'field_test'), array('node', 'page', 'default', 'test'))), 'd6_node' => array(array(array(1), array(1)), array(array(2), array(2)), array(array(3), array(3))));
     $this->prepareMigrations($id_mappings);
     $migrations = entity_load_multiple('migration', array('d6_cck_field_values:*'));
     foreach ($migrations as $migration) {
         $executable = new MigrateExecutable($migration, $this);
         $executable->import();
     }
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:35,代码来源:MigrateCckFieldValuesTest.php


示例5: prepareView

 /**
  * {@inheritdoc}
  *
  * Mark the accessible IDs a user can see. We do not unset unaccessible
  * values, as other may want to act on those values, even if they can
  * not be accessed.
  */
 public function prepareView(array $entities_items)
 {
     $target_ids = array();
     // Collect every possible entity attached to any of the entities.
     foreach ($entities_items as $items) {
         foreach ($items as $item) {
             if (!empty($item->target_id)) {
                 $target_ids[] = $item->target_id;
             }
         }
     }
     $target_type = $this->getFieldSetting('target_type');
     $target_entities = array();
     if ($target_ids) {
         $target_entities = entity_load_multiple($target_type, $target_ids);
     }
     // Iterate through the fieldable entities again to attach the loaded data.
     foreach ($entities_items as $items) {
         $rekey = FALSE;
         foreach ($items as $item) {
             if ($item->target_id !== 0 && !isset($target_entities[$item->target_id])) {
                 // The entity no longer exists, so empty the item.
                 $item->setValue(NULL);
                 $rekey = TRUE;
                 continue;
             }
             $item->originalEntity = $target_entities[$item->target_id];
         }
         // Re-key the items array if needed.
         if ($rekey) {
             $items->filterEmptyItems();
         }
     }
 }
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:41,代码来源:EntityReferenceFormatterBase.php


示例6: testTagsField

 public function testTagsField()
 {
     $this->drupalLogin($this->admin_user);
     $this->drupalGet('node/add/page');
     $title_key = 'title[0][value]';
     $body_key = 'body[0][value]';
     // Fill in node creation form and preview node.
     $edit = array();
     $edit[$title_key] = $this->randomMachineName(8);
     $edit[$body_key] = $this->randomMachineName(16);
     $edit['tags'] = 'tag1, tag2, tag3';
     $this->drupalPostForm('node/add/page', $edit, t('Save and publish'));
     $tags = entity_load_multiple('taxonomy_term');
     foreach ($tags as $tag) {
         $this->assertSitemapLinkValues('taxonomy_term', $tag->id(), array('status' => 0, 'priority' => 0.5, 'changefreq' => 0));
         $tag->delete();
     }
     xmlsitemap_link_bundle_settings_save('taxonomy_term', 'tags', array('status' => 1, 'priority' => 0.2, 'changefreq' => XMLSITEMAP_FREQUENCY_HOURLY));
     $this->drupalPostForm('node/add/page', $edit, t('Save and publish'));
     $tags = entity_load_multiple('taxonomy_term');
     foreach ($tags as $tag) {
         $this->assertSitemapLinkValues('taxonomy_term', $tag->id(), array('status' => 1, 'priority' => 0.2, 'changefreq' => XMLSITEMAP_FREQUENCY_HOURLY));
         $tag->delete();
     }
 }
开发者ID:jeroenos,项目名称:jeroenos_d8.mypressonline.com,代码行数:25,代码来源:XmlSitemapNodeFunctionalTest.php


示例7: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create a new content type
     $content_type = $this->drupalCreateContentType();
     // Add a node of the new content type.
     $node_data = array('type' => $content_type->type);
     $this->container->get('comment.manager')->addDefaultField('node', $content_type->type);
     $this->node = $this->drupalCreateNode($node_data);
     // Force a flush of the in-memory storage.
     $this->container->get('views.views_data')->clear();
     // Create some comments and attach them to the created node.
     for ($i = 0; $i < $this->masterDisplayResults; $i++) {
         /** @var \Drupal\comment\CommentInterface $comment */
         $comment = entity_create('comment', array('status' => CommentInterface::PUBLISHED, 'field_name' => 'comment', 'entity_type' => 'node', 'entity_id' => $this->node->id()));
         $comment->setOwnerId(0);
         $comment->setSubject('Test comment ' . $i);
         $comment->comment_body->value = 'Test body ' . $i;
         $comment->comment_body->format = 'full_html';
         // Ensure comments are sorted in ascending order.
         $time = REQUEST_TIME + ($this->masterDisplayResults - $i);
         $comment->setCreatedTime($time);
         $comment->changed->value = $time;
         $comment->save();
     }
     // Store all the nodes just created to access their properties on the tests.
     $this->commentsCreated = entity_load_multiple('comment');
     // Sort created comments in descending order.
     ksort($this->commentsCreated, SORT_NUMERIC);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:30,代码来源:DefaultViewRecentCommentsTest.php


示例8: setUp

 /**
  * Set up an administrative user account and testing keys.
  */
 public function setUp()
 {
     // Call parent::setUp() allowing test cases to pass further modules.
     parent::setUp();
     $this->admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'administer site configuration', 'administer xmlsitemap', 'access content'));
     $this->drupalLogin($this->admin_user);
     if (!$this->languageManager->getLanguage('fr')) {
         // Add a new language.
         $language = new Language(array('id' => 'fr', 'name' => 'French'));
         language_save($language);
     }
     if (!$this->languageManager->getLanguage('en')) {
         // Add a new language.
         $language = new Language(array('id' => 'en', 'name' => 'English'));
         language_save($language);
     }
     // Create the two different language-context sitemaps.
     $previous_sitemaps = entity_load_multiple('xmlsitemap');
     foreach ($previous_sitemaps as $previous_sitemap) {
         $previous_sitemap->delete();
     }
     $sitemap = $this->entityManager->getStorage('xmlsitemap')->create(array());
     $sitemap->context = array('language' => 'en');
     xmlsitemap_sitemap_save($sitemap);
     $sitemap = $this->entityManager->getStorage('xmlsitemap')->create(array());
     $sitemap->context = array('language' => 'fr');
     xmlsitemap_sitemap_save($sitemap);
 }
开发者ID:jeroenos,项目名称:jeroenos_d8.mypressonline.com,代码行数:31,代码来源:XmlSitemapMultilingualTestBase.php


示例9: testThemeBreakpointGroup

 /**
  * Test the breakpoints defined by the custom group.
  */
 public function testThemeBreakpointGroup()
 {
     // Verify the breakpoint group 'test' was created by breakpoint_test_theme.
     $breakpoint_group_obj = entity_create('breakpoint_group', array('label' => 'Test Theme', 'name' => 'test', 'sourceType' => Breakpoint::SOURCE_TYPE_THEME, 'source' => 'breakpoint_test_theme', 'id' => Breakpoint::SOURCE_TYPE_THEME . '.breakpoint_test_theme.test'));
     $breakpoint_group_obj->addBreakpoints(entity_load_multiple('breakpoint', array('theme.breakpoint_test_theme.mobile', 'theme.breakpoint_test_theme.narrow', 'theme.breakpoint_test_theme.wide')));
     // Verify we can load this breakpoint defined by the theme.
     $this->verifyBreakpointGroup($breakpoint_group_obj);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:11,代码来源:BreakpointThemeTest.php


示例10: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     foreach (entity_load_multiple('taxonomy_vocabulary') as $voc) {
         $this->derivatives[$voc->vid] = $base_plugin_definition;
         $this->derivatives[$voc->vid]['admin_label'] = t('Tags in @voc', array('@voc' => $voc->name));
     }
     return $this->derivatives;
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:11,代码来源:TagcloudsTermsBlock.php


示例11: prepareView

 /**
  * {@inheritdoc}
  *
  * Mark the accessible IDs a user can see. We do not unset unaccessible
  * values, as other may want to act on those values, even if they can
  * not be accessed.
  */
 public function prepareView(array $entities_items)
 {
     $target_ids = array();
     $revision_ids = array();
     // Collect every possible entity attached to any of the entities.
     foreach ($entities_items as $items) {
         foreach ($items as $item) {
             if (!empty($item->revision_id)) {
                 $revision_ids[] = $item->revision_id;
             } elseif (!empty($item->target_id)) {
                 $target_ids[] = $item->target_id;
             }
         }
     }
     $target_type = $this->getFieldSetting('target_type');
     $target_entities = array();
     if ($target_ids) {
         $target_entities = entity_load_multiple($target_type, $target_ids);
     }
     if ($revision_ids) {
         // We need to load the revisions one by-one.
         foreach ($revision_ids as $revision_id) {
             $target_entity = entity_revision_load($target_type, $revision_id);
             // Use the revision ID in the key.
             $identifier = $target_entity->id() . ':' . $revision_id;
             $target_entities[$identifier] = $target_entity;
         }
     }
     // Iterate through the fieldable entities again to attach the loaded data.
     foreach ($entities_items as $items) {
         $rekey = FALSE;
         foreach ($items as $item) {
             // If we have a revision ID, the key uses it as well.
             $identifier = !empty($item->revision_id) ? $item->target_id . ':' . $item->revision_id : $item->target_id;
             if ($item->target_id !== 0) {
                 if (!isset($target_entities[$identifier])) {
                     // The entity no longer exists, so empty the item.
                     $item->setValue(NULL);
                     $rekey = TRUE;
                     continue;
                 }
                 $item->entity = $target_entities[$identifier];
                 if (!$item->entity->access('view')) {
                     continue;
                 }
             } else {
                 // This is an "auto_create" item, just leave the entity in place.
             }
             // Mark item as accessible.
             $item->access = TRUE;
         }
         // Rekey the items array if needed.
         if ($rekey) {
             $items->filterEmptyItems();
         }
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:64,代码来源:EntityReferenceFormatterBase.php


示例12: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     $block_contents = entity_load_multiple('block_content');
     foreach ($block_contents as $block_content) {
         $this->derivatives[$block_content->uuid()] = $base_plugin_definition;
         $this->derivatives[$block_content->uuid()]['admin_label'] = $block_content->label();
     }
     return parent::getDerivativeDefinitions($base_plugin_definition);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:12,代码来源:BlockContent.php


示例13: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     /** @var \Drupal\migrate\entity\Migration $migration */
     $migrations = entity_load_multiple('migration', array('d6_term_node:*'));
     foreach ($migrations as $migration) {
         $executable = new MigrateExecutable($migration, $this);
         $executable->import();
     }
 }
开发者ID:dev981,项目名称:gaptest,代码行数:13,代码来源:MigrateTermNodeTest.php


示例14: buildOptionsForm

 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     $vocabularies = entity_load_multiple('taxonomy_vocabulary');
     $options = array();
     foreach ($vocabularies as $voc) {
         $options[$voc->id()] = $voc->label();
     }
     $form['vids'] = array('#type' => 'checkboxes', '#title' => $this->t('Vocabularies'), '#options' => $options, '#default_value' => $this->options['vids'], '#description' => $this->t('Choose which vocabularies you wish to relate. Remember that every term found will create a new record, so this relationship is best used on just one vocabulary that has only one term per node.'));
     parent::buildOptionsForm($form, $form_state);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:10,代码来源:NodeTermData.php


示例15: preRender

 public function preRender($result)
 {
     $cids = array();
     foreach ($result as $row) {
         $cids[] = $row->cid;
     }
     $this->comments = entity_load_multiple('comment', $cids);
     foreach ($this->comments as $comment) {
         $comment->depth = count(explode('.', $comment->getThread())) - 1;
     }
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:11,代码来源:Rss.php


示例16: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     $block_contents = entity_load_multiple('block_content');
     /** @var $block_content \Drupal\block_content\Entity\BlockContent */
     foreach ($block_contents as $block_content) {
         $this->derivatives[$block_content->uuid()] = $base_plugin_definition;
         $this->derivatives[$block_content->uuid()]['admin_label'] = $block_content->label();
         $this->derivatives[$block_content->uuid()]['config_dependencies']['content'] = array($block_content->getConfigDependencyName());
     }
     return parent::getDerivativeDefinitions($base_plugin_definition);
 }
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:14,代码来源:BlockContent.php


示例17: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $id_mappings = array('d6_term_node' => array(array(array(2), array(1))), 'd6_node_revision' => array(array(array(2), array(2))));
     $this->prepareMigrations($id_mappings);
     /** @var \Drupal\migrate\entity\Migration $migration */
     $migrations = entity_load_multiple('migration', array('d6_term_node_revision:*'));
     foreach ($migrations as $migration) {
         $executable = new MigrateExecutable($migration, $this);
         $executable->import();
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:15,代码来源:MigrateTermNodeRevisionTest.php


示例18: testDrupal

 /**
  * Test the complete Drupal migration.
  */
 public function testDrupal()
 {
     $dumps = $this->getDumps();
     $this->loadDumps($dumps);
     $classes = $this->getTestClassesList();
     $extension_install_storage = new ExtensionInstallStorage(\Drupal::service('config.storage'), InstallStorage::CONFIG_OPTIONAL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION, TRUE);
     foreach ($classes as $class) {
         if (is_subclass_of($class, '\\Drupal\\migrate\\Tests\\MigrateDumpAlterInterface')) {
             $class::migrateDumpAlter($this);
         }
     }
     // Run every migration in the order specified by the storage controller.
     foreach (entity_load_multiple('migration', static::$migrations) as $migration) {
         (new MigrateExecutable($migration, $this))->import();
         // Ensure that the default migration has the correct dependencies.
         list($base_name, ) = explode(':', $migration->id(), 2);
         $default_configuration = $extension_install_storage->read('migrate.migration.' . $base_name);
         $default_dependencies = isset($default_configuration['dependencies']) ? $default_configuration['dependencies'] : [];
         $this->assertEqual($default_dependencies, $migration->getDependencies(), SafeMarkup::format('Dependencies in @id match after installing. Default configuration @first is equal to active configuration @second.', array('@id' => $migration->id(), '@first' => var_export($default_dependencies, TRUE), '@second' => var_export($migration->getDependencies(), TRUE))));
     }
     foreach ($classes as $class) {
         $test_object = new $class($this->testId);
         $test_object->databasePrefix = $this->databasePrefix;
         $test_object->container = $this->container;
         // run() does a lot of setup and tear down work which we don't need:
         // it would setup a new database connection and wouldn't find the
         // Drupal dump. Also by skipping the setUp() methods there are no id
         // mappings or entities prepared. The tests run against solely migrated
         // data.
         foreach (get_class_methods($test_object) as $method) {
             if (strtolower(substr($method, 0, 4)) == 'test') {
                 // Insert a fail record. This will be deleted on completion to ensure
                 // that testing completed.
                 $method_info = new \ReflectionMethod($class, $method);
                 $caller = array('file' => $method_info->getFileName(), 'line' => $method_info->getStartLine(), 'function' => $class . '->' . $method . '()');
                 $completion_check_id = TestBase::insertAssert($this->testId, $class, FALSE, 'The test did not complete due to a fatal error.', 'Completion check', $caller);
                 // Run the test method.
                 try {
                     $test_object->{$method}();
                 } catch (\Exception $e) {
                     $this->exceptionHandler($e);
                 }
                 // Remove the completion check record.
                 TestBase::deleteAssert($completion_check_id);
             }
         }
         // Add the pass/fail/exception/debug results.
         foreach ($this->results as $key => &$value) {
             $value += $test_object->results[$key];
         }
     }
 }
开发者ID:jeyram,项目名称:camp-gdl,代码行数:55,代码来源:MigrateFullDrupalTestBase.php


示例19: buildOptionsForm

 public function buildOptionsForm(&$form, &$form_state)
 {
     $form['term_page'] = array('#type' => 'checkbox', '#title' => t('Load default filter from term page'), '#default_value' => $this->options['term_page']);
     $form['node'] = array('#type' => 'checkbox', '#title' => t('Load default filter from node page, that\'s good for related taxonomy blocks'), '#default_value' => $this->options['node']);
     $form['limit'] = array('#type' => 'checkbox', '#title' => t('Limit terms by vocabulary'), '#default_value' => $this->options['limit'], '#states' => array('visible' => array(':input[name="options[argument_default][taxonomy_tid][node]"]' => array('checked' => TRUE))));
     $options = array();
     $vocabularies = entity_load_multiple('taxonomy_vocabulary');
     foreach ($vocabularies as $voc) {
         $options[$voc->id()] = $voc->label();
     }
     $form['vids'] = array('#type' => 'checkboxes', '#title' => t('Vocabularies'), '#options' => $options, '#default_value' => $this->options['vids'], '#states' => array('visible' => array(':input[name="options[argument_default][taxonomy_tid][limit]"]' => array('checked' => TRUE), ':input[name="options[argument_default][taxonomy_tid][node]"]' => array('checked' => TRUE))));
     $form['anyall'] = array('#type' => 'radios', '#title' => t('Multiple-value handling'), '#default_value' => $this->options['anyall'], '#options' => array(',' => t('Filter to items that share all terms'), '+' => t('Filter to items that share any term')), '#states' => array('visible' => array(':input[name="options[argument_default][taxonomy_tid][node]"]' => array('checked' => TRUE))));
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:13,代码来源:Tid.php


示例20: testExportImport

 /**
  * Tests a simple site export import case.
  */
 public function testExportImport()
 {
     $this->originalSlogan = \Drupal::config('system.site')->get('slogan');
     $this->newSlogan = $this->randomString(16);
     $this->assertNotEqual($this->newSlogan, $this->originalSlogan);
     \Drupal::config('system.site')->set('slogan', $this->newSlogan)->save();
     $this->assertEqual(\Drupal::config('system.site')->get('slogan'), $this->newSlogan);
     // Create a content type.
     $this->content_type = $this->drupalCreateContentType();
     // Create a field.
     $this->fieldName = drupal_strtolower($this->randomMachineName());
     $this->fieldStorage = entity_create('field_storage_config', array('field_name' => $this->fieldName, 'entity_type' => 'node', 'type' => 'text'));
     $this->fieldStorage->save();
     entity_create('field_config', array('field_storage' => $this->fieldStorage, 'bundle' => $this->content_type->type))->save();
     entity_get_form_display('node', $this->content_type->type, 'default')->setComponent($this->fieldName, array('type' => 'text_textfield'))->save();
     entity_get_display('node', $this->content_type->type, 'full')->setComponent($this->fieldName)->save();
     $this->drupalGet('node/add/' . $this->content_type->type);
     $this->assertFieldByName("{$this->fieldName}[0][value]", '', 'Widget is displayed');
     // Export the configuration.
     $this->drupalPostForm('admin/config/development/configuration/full/export', array(), 'Export');
     $this->tarball = $this->drupalGetContent();
     \Drupal::config('system.site')->set('slogan', $this->originalSlogan)->save();
     $this->assertEqual(\Drupal::config('system.site')->get('slogan'), $this->originalSlogan);
     // Delete the custom field.
     $fields = entity_load_multiple('field_config');
     foreach ($fields as $field) {
         if ($field->field_name == $this->fieldName) {
             $field->delete();
         }
     }
     $field_storages = entity_load_multiple('field_storage_config');
     foreach ($field_storages as $field_storage) {
         if ($field_storage->field_name == $this->fieldName) {
             $field_storage->delete();
         }
     }
     $this->drupalGet('node/add/' . $this->content_type->type);
     $this->assertNoFieldByName("{$this->fieldName}[0][value]", '', 'Widget is not displayed');
     // Import the configuration.
     $filename = 'temporary://' . $this->randomMachineName();
     file_put_contents($filename, $this->tarball);
     $this->drupalPostForm('admin/config/development/configuration/full/import', array('files[import_tarball]' => $filename), 'Upload');
     $this->drupalPostForm(NULL, array(), 'Import all');
     $this->assertEqual(\Drupal::config('system.site')->get('slogan'), $this->newSlogan);
     $this->drupalGet('node/add');
     $this->assertFieldByName("{$this->fieldName}[0][value]", '', 'Widget is displayed');
     \Drupal::config('system.site')->set('slogan', $this->originalSlogan)->save();
     $this->drupalGet('admin/config/development/configuration');
     $this->assertText('Your current configuration has changed. Changes to these configuration items will be lost on the next synchronization: system.site');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:53,代码来源:ConfigExportImportUITest.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP entity_load_multiple_by_properties函数代码示例发布时间:2022-05-15
下一篇:
PHP entity_load函数代码示例发布时间: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