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

PHP entity_get_display函数代码示例

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

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



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

示例1: testBlockFields

 /**
  * Checks block edit functionality.
  */
 public function testBlockFields()
 {
     $this->drupalLogin($this->adminUser);
     $this->blockType = $this->createBlockContentType('link');
     // Create a field with settings to validate.
     $this->fieldStorage = entity_create('field_storage_config', array('name' => drupal_strtolower($this->randomName()), 'entity_type' => 'block_content', 'type' => 'link', 'cardinality' => 2));
     $this->fieldStorage->save();
     $this->instance = entity_create('field_instance_config', array('field_storage' => $this->fieldStorage, 'bundle' => 'link', 'settings' => array('title' => DRUPAL_OPTIONAL)));
     $this->instance->save();
     entity_get_form_display('block_content', 'link', 'default')->setComponent($this->fieldStorage->getName(), array('type' => 'link_default'))->save();
     entity_get_display('block_content', 'link', 'default')->setComponent($this->fieldStorage->getName(), array('type' => 'link', 'label' => 'hidden'))->save();
     // Create a block.
     $this->drupalGet('block/add/link');
     $edit = array('info[0][value]' => $this->randomName(8), $this->fieldStorage->getName() . '[0][url]' => 'http://example.com', $this->fieldStorage->getName() . '[0][title]' => 'Example.com');
     $this->drupalPostForm(NULL, $edit, t('Save'));
     $block = entity_load('block_content', 1);
     $url = 'admin/structure/block/add/block_content:' . $block->uuid() . '/' . \Drupal::config('system.theme')->get('default');
     // Place the block.
     $instance = array('id' => drupal_strtolower($edit['info[0][value]']), 'settings[label]' => $edit['info[0][value]'], 'region' => 'sidebar_first');
     $this->drupalPostForm($url, $instance, t('Save block'));
     // Navigate to home page.
     $this->drupalGet('<front>');
     $this->assertLinkByHref('http://example.com');
     $this->assertText('Example.com');
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:28,代码来源:BlockContentFieldTest.php


示例2: _testTextfieldWidgets

 /**
  * Helper function for testTextfieldWidgets().
  */
 function _testTextfieldWidgets($field_type, $widget_type)
 {
     // Create a field.
     $field_name = Unicode::strtolower($this->randomMachineName());
     $field_storage = FieldStorageConfig::create(array('field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => $field_type));
     $field_storage->save();
     FieldConfig::create(['field_storage' => $field_storage, 'bundle' => 'entity_test', 'label' => $this->randomMachineName() . '_label'])->save();
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($field_name, array('type' => $widget_type, 'settings' => array('placeholder' => 'A placeholder on ' . $widget_type)))->save();
     entity_get_display('entity_test', 'entity_test', 'full')->setComponent($field_name)->save();
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed');
     $this->assertNoFieldByName("{$field_name}[0][format]", '1', 'Format selector is not displayed');
     $this->assertRaw(format_string('placeholder="A placeholder on @widget_type"', array('@widget_type' => $widget_type)));
     // Submit with some value.
     $value = $this->randomMachineName();
     $edit = array("{$field_name}[0][value]" => $value);
     $this->drupalPostForm(NULL, $edit, t('Save'));
     preg_match('|entity_test/manage/(\\d+)|', $this->url, $match);
     $id = $match[1];
     $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
     // Display the entity.
     $entity = EntityTest::load($id);
     $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
     $content = $display->build($entity);
     $this->setRawContent(\Drupal::service('renderer')->renderRoot($content));
     $this->assertText($value, 'Filtered tags are not displayed');
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:31,代码来源:StringFieldTest.php


示例3: getSelectedEditor

 /**
  * Returns the in-place editor that Edit selects.
  */
 protected function getSelectedEditor($entity_id, $field_name, $view_mode = 'default')
 {
     $entity = entity_load('entity_test', $entity_id, TRUE);
     $items = $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get($field_name);
     $options = entity_get_display('entity_test', 'entity_test', $view_mode)->getComponent($field_name);
     return $this->editorSelector->getEditor($options['type'], $items);
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:10,代码来源:QuickEditIntegrationTest.php


示例4: testSubscriptionVisiblity

 /**
  * Test subscription output visibility for different users.
  */
 public function testSubscriptionVisiblity()
 {
     // Enable the extra field.
     entity_get_display('user', 'user', 'default')->setComponent('simplenews', array('label' => 'hidden', 'type' => 'simplenews'))->save();
     // Create admin user.
     $admin_user = $this->drupalCreateUser(array('administer users'));
     // Create user that can view user profiles.
     $user = $this->drupalCreateUser(array('access user profiles', 'subscribe to newsletters', 'access content'));
     $this->drupalLogin($admin_user);
     // Tests extra fields for admin user.
     $this->drupalGet('user/' . $admin_user->id());
     $this->assertLink('Manage subscriptions');
     $this->drupalLogout();
     // Tests extra fields for user.
     $this->drupalLogin($user);
     $this->drupalGet('user/' . $admin_user->id());
     $this->assertNoLink('Manage subscriptions');
     $this->drupalGet('user/' . $user->id());
     $this->assertLink('Manage subscriptions');
     $this->drupalLogout();
     // Tests extra fields for anonymous users.
     $this->drupalGet('user/' . $admin_user->id());
     $this->assertNoLink('Manage subscriptions');
     $this->drupalGet('user/' . $user->id());
     $this->assertNoLink('Manage subscriptions');
 }
开发者ID:aritnath1990,项目名称:simplenewslatest,代码行数:29,代码来源:SimplenewsTestSubscriptionOutput.php


示例5: testUserPictureEntityDisplay

 /**
  * Tests the Drupal 7 user picture to Drupal 8 entity display migration.
  */
 public function testUserPictureEntityDisplay()
 {
     $component = entity_get_display('user', 'user', 'default')->getComponent('user_picture');
     $this->assertIdentical('image', $component['type']);
     $this->assertIdentical('', $component['settings']['image_style']);
     $this->assertIdentical('content', $component['settings']['image_link']);
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:10,代码来源:MigrateUserPictureEntityDisplayTest.php


示例6: testEmailField

 /**
  * Tests email field.
  */
 function testEmailField()
 {
     // Create a field with settings to validate.
     $field_name = Unicode::strtolower($this->randomMachineName());
     $this->fieldStorage = FieldStorageConfig::create(array('field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'email'));
     $this->fieldStorage->save();
     $this->field = FieldConfig::create(['field_storage' => $this->fieldStorage, 'bundle' => 'entity_test']);
     $this->field->save();
     // Create a form display for the default form mode.
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($field_name, array('type' => 'email_default', 'settings' => array('placeholder' => '[email protected]')))->save();
     // Create a display for the full view mode.
     entity_get_display('entity_test', 'entity_test', 'full')->setComponent($field_name, array('type' => 'email_mailto'))->save();
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget found.');
     $this->assertRaw('placeholder="[email protected]"');
     // Submit a valid email address and ensure it is accepted.
     $value = '[email protected]';
     $edit = array("{$field_name}[0][value]" => $value);
     $this->drupalPostForm(NULL, $edit, t('Save'));
     preg_match('|entity_test/manage/(\\d+)|', $this->url, $match);
     $id = $match[1];
     $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
     $this->assertRaw($value);
     // Verify that a mailto link is displayed.
     $entity = EntityTest::load($id);
     $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
     $content = $display->build($entity);
     $this->setRawContent(\Drupal::service('renderer')->renderRoot($content));
     $this->assertLinkByHref('mailto:[email protected]');
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:34,代码来源:EmailFieldTest.php


示例7: testVideo

 function testVideo()
 {
     $field_name = Unicode::strtolower($this->randomMachineName());
     // Create a field.
     $field_storage = entity_create('field_storage_config', array('field_name' => $field_name, 'entity_type' => 'node', 'translatable' => FALSE, 'type' => 'youtube', 'cardinality' => '1'));
     $field_storage->save();
     $field = entity_create('field_config', array('field_storage' => $field_storage, 'bundle' => 'article', 'title' => DRUPAL_DISABLED));
     $field->save();
     entity_get_form_display('node', 'article', 'default')->setComponent($field_name, array('type' => 'youtube', 'settings' => array()))->save();
     entity_get_display('node', 'article', 'full')->setComponent($field_name, array('type' => 'youtube_video'))->save();
     // Display creation form.
     $this->drupalGet('node/add/article');
     $this->assertFieldByName("{$field_name}[0][input]", '', t('Video input field is displayed'));
     // Verify that a valid URL can be submitted.
     $video_id = 'T5y3dJYHb_A';
     $value = 'http://www.youtube.com/watch?v=' . $video_id;
     $embed_value = 'http://www.youtube.com/embed/' . $video_id;
     $edit = array("title[0][value]" => 'Test', "{$field_name}[0][input]" => $value);
     $this->drupalPostForm(NULL, $edit, t('Save and publish'));
     preg_match('|/node/(\\d+)|', $this->url, $match);
     $this->assertText(t('Article Test has been created.'));
     $this->assertRaw($embed_value);
     // Verify thta the video is displayed.
     $pattern = '<iframe.*src="' . $embed_value;
     $pattern = str_replace('/', '\\/', $pattern);
     $pattern = '/' . $pattern . '/s';
     $this->assertPattern($pattern);
     // Verify that invalid URLs cannot be submitted.
     $this->drupalGet('node/add/article');
     $value = 'not-a-url';
     $edit = array("title[0][value]" => 'Test1', "{$field_name}[0][input]" => $value);
     $this->drupalPostForm(NULL, $edit, t('Save and publish'));
     $this->assertText(t('Please provide a valid YouTube URL.'));
 }
开发者ID:neeravbm,项目名称:unify-d8,代码行数:34,代码来源:YouTubeTest.php


示例8: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installConfig(['system']);
     $this->installConfig(['field']);
     $this->installConfig(['text']);
     $this->installConfig(['address']);
     $this->installEntitySchema('entity_test');
     ConfigurableLanguage::createFromLangcode('zh-hant')->save();
     // The address module is never installed, so the importer doesn't run
     // automatically. Instead, we manually import the address formats we need.
     $country_codes = ['AD', 'SV', 'TW', 'US', 'ZZ'];
     $importer = \Drupal::service('address.address_format_importer');
     $importer->importEntities($country_codes);
     $importer->importTranslations(['zh-hant']);
     $this->entityType = 'entity_test';
     $this->bundle = $this->entityType;
     $this->fieldName = Unicode::strtolower($this->randomMachineName());
     $field_storage = FieldStorageConfig::create(['field_name' => $this->fieldName, 'entity_type' => $this->entityType, 'type' => 'address']);
     $field_storage->save();
     $field = FieldConfig::create(['field_storage' => $field_storage, 'bundle' => $this->bundle, 'label' => $this->randomMachineName()]);
     $field->save();
     $this->display = entity_get_display($this->entityType, $this->bundle, 'default');
     $this->display->setComponent($this->fieldName, ['type' => 'address_plain', 'settings' => []]);
     $this->display->save();
 }
开发者ID:r-daneelolivaw,项目名称:chalk,代码行数:29,代码来源:PlainFormatterTest.php


示例9: testFieldItemAttributes

 /**
  * Tests field item attributes.
  */
 public function testFieldItemAttributes()
 {
     // Make sure the test field will be rendered.
     entity_get_display('entity_test', 'entity_test', 'default')->setComponent('field_test_text', array('type' => 'text_default'))->save();
     // Create an entity and save test value in field_test_text.
     $test_value = $this->randomMachineName();
     $entity = entity_create('entity_test');
     $entity->field_test_text = $test_value;
     $entity->save();
     // Browse to the entity and verify that the attribute is rendered in the
     // field item HTML markup.
     $this->drupalGet('entity_test/' . $entity->id());
     $xpath = $this->xpath('//div[@data-field-item-attr="foobar"]/p[text()=:value]', array(':value' => $test_value));
     $this->assertTrue($xpath, 'The field item attribute has been found in the rendered output of the field.');
     // Enable the RDF module to ensure that two modules can add attributes to
     // the same field item.
     \Drupal::service('module_installer')->install(array('rdf'));
     $this->resetAll();
     // Set an RDF mapping for the field_test_text field. This RDF mapping will
     // be turned into RDFa attributes in the field item output.
     $mapping = rdf_get_mapping('entity_test', 'entity_test');
     $mapping->setFieldMapping('field_test_text', array('properties' => array('schema:text')))->save();
     // Browse to the entity and verify that the attributes from both modules
     // are rendered in the field item HTML markup.
     $this->drupalGet('entity_test/' . $entity->id());
     $xpath = $this->xpath('//div[@data-field-item-attr="foobar" and @property="schema:text"]/p[text()=:value]', array(':value' => $test_value));
     $this->assertTrue($xpath, 'The field item attributes from both modules have been found in the rendered output of the field.');
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:31,代码来源:EntityViewControllerTest.php


示例10: getSelectedEditor

 /**
  * Returns the in-place editor that Quick Edit selects.
  */
 protected function getSelectedEditor($entity_id, $field_name, $view_mode = 'default')
 {
     $entity = entity_load('entity_test', $entity_id, TRUE);
     $items = $entity->get($field_name);
     $options = entity_get_display('entity_test', 'entity_test', $view_mode)->getComponent($field_name);
     return $this->editorSelector->getEditor($options['type'], $items);
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:10,代码来源:EditorSelectionTest.php


示例11: testBooleanField

 /**
  * Tests boolean field.
  */
 function testBooleanField()
 {
     $on = $this->randomMachineName();
     $off = $this->randomMachineName();
     $label = $this->randomMachineName();
     // Create a field with settings to validate.
     $field_name = drupal_strtolower($this->randomMachineName());
     $this->field_storage = FieldStorageConfig::create(array('field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'boolean', 'settings' => array('on_label' => $on, 'off_label' => $off)));
     $this->field_storage->save();
     $this->field = FieldConfig::create(array('field_name' => $field_name, 'entity_type' => 'entity_test', 'bundle' => 'entity_test', 'label' => $label, 'required' => TRUE));
     $this->field->save();
     // Create a form display for the default form mode.
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($field_name, array('type' => 'boolean_checkbox'))->save();
     // Create a display for the full view mode.
     entity_get_display('entity_test', 'entity_test', 'full')->setComponent($field_name, array('type' => 'boolean'))->save();
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[value]", '', 'Widget found.');
     $this->assertRaw($on);
     // Submit and ensure it is accepted.
     $edit = array("{$field_name}[value]" => 1);
     $this->drupalPostForm(NULL, $edit, t('Save'));
     preg_match('|entity_test/manage/(\\d+)|', $this->url, $match);
     $id = $match[1];
     $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
     // Verify that boolean value is displayed.
     $entity = entity_load('entity_test', $id);
     $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
     $content = $display->build($entity);
     $this->drupalSetContent(drupal_render($content));
     $this->assertRaw('<div class="field-item">' . $on . '</div>');
     // Test the display_label option.
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($field_name, array('type' => 'boolean_checkbox', 'settings' => array('display_label' => TRUE)))->save();
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[value]", '', 'Widget found.');
     $this->assertNoRaw($on);
     $this->assertText($this->field->label());
     // Go to the form display page and check if the default settings works as
     // expected.
     $fieldEditUrl = 'entity_test/structure/entity_test/form-display';
     $this->drupalGet($fieldEditUrl);
     // Click on the widget settings button to open the widget settings form.
     $this->drupalPostAjaxForm(NULL, array(), $field_name . "_settings_edit");
     $this->assertText('Use field label instead of the "On label" as label', t('Display setting checkbox available.'));
     // Enable setting.
     $edit = array('fields[' . $field_name . '][settings_edit_form][settings][display_label]' => 1);
     $this->drupalPostAjaxForm(NULL, $edit, $field_name . "_plugin_settings_update");
     $this->drupalPostForm(NULL, NULL, 'Save');
     // Go again to the form display page and check if the setting
     // is stored and has the expected effect.
     $this->drupalGet($fieldEditUrl);
     $this->assertText('Use field label: Yes', 'Checking the display settings checkbox updated the value.');
     $this->drupalPostAjaxForm(NULL, array(), $field_name . "_settings_edit");
     $this->assertText('Use field label instead of the "On label" as label', t('Display setting checkbox is available'));
     $this->assertFieldByXPath('*//input[@id="edit-fields-' . $field_name . '-settings-edit-form-settings-display-label" and @value="1"]', TRUE, t('Display label changes label of the checkbox'));
     // Test the boolean field settings.
     $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.' . $field_name . '/storage');
     $this->assertFieldById('edit-field-storage-settings-on-label', $on);
     $this->assertFieldById('edit-field-storage-settings-off-label', $off);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:63,代码来源:BooleanFieldTest.php


示例12: setUp

 function setUp()
 {
     parent::setUp();
     // Create test user.
     $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'bypass node access'));
     $this->drupalLogin($admin_user);
     // Create content type, with underscores.
     $type_name = strtolower($this->randomMachineName(8)) . '_test';
     $type = $this->drupalCreateContentType(array('name' => $type_name, 'type' => $type_name));
     $this->type = $type->id();
     $display = entity_get_display('node', $type_name, 'default');
     // Create a node.
     $node_values = array('type' => $type_name);
     // Create test fields.
     $test_fields = array('field_test', 'field_test_2', 'field_no_access');
     foreach ($test_fields as $field_name) {
         $field_storage = FieldStorageConfig::create(['field_name' => $field_name, 'entity_type' => 'node', 'type' => 'test_field']);
         $field_storage->save();
         $instance = FieldConfig::create(['field_storage' => $field_storage, 'bundle' => $type_name, 'label' => $this->randomMachineName()]);
         $instance->save();
         // Assign a test value for the field.
         $node_values[$field_name][0]['value'] = mt_rand(1, 127);
         // Set the field visible on the display object.
         $display_options = array('label' => 'above', 'type' => 'field_test_default', 'settings' => array('test_formatter_setting' => $this->randomMachineName()));
         $display->setComponent($field_name, $display_options);
     }
     // Save display + create node.
     $display->save();
     $this->node = $this->drupalCreateNode($node_values);
 }
开发者ID:frankcr,项目名称:sftw8,代码行数:30,代码来源:EntityDisplayTest.php


示例13: setUp

 function setUp()
 {
     parent::setUp();
     // Configure the theme system.
     $this->installConfig(array('system', 'field'));
     $this->installEntitySchema('entity_test');
     // @todo Add helper methods for all of the following.
     $this->entity_type = 'entity_test';
     if (!isset($this->bundle)) {
         $this->bundle = $this->entity_type;
     }
     $this->field_name = drupal_strtolower($this->randomName());
     $this->field_type = 'text_long';
     $this->field_settings = array();
     $this->instance_settings = array('text_processing' => FALSE);
     $this->formatter_type = 'string';
     $this->formatter_settings = array();
     $this->fieldStorage = entity_create('field_storage_config', array('name' => $this->field_name, 'entity_type' => $this->entity_type, 'type' => $this->field_type, 'settings' => $this->field_settings));
     $this->fieldStorage->save();
     $this->instance = entity_create('field_instance_config', array('field_storage' => $this->fieldStorage, 'bundle' => $this->bundle, 'label' => $this->randomName(), 'settings' => $this->instance_settings));
     $this->instance->save();
     $this->view_mode = 'default';
     $this->display = entity_get_display($this->entity_type, $this->bundle, $this->view_mode)->setComponent($this->field_name, array('type' => $this->formatter_type, 'settings' => $this->formatter_settings));
     $this->display->save();
     $this->langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:26,代码来源:TextPlainUnitTest.php


示例14: testReEnabledField

 /**
  * Test the behavior of a field module after being disabled and re-enabled.
  */
 function testReEnabledField()
 {
     // Add a telephone field to the article content type.
     $field_storage = entity_create('field_storage_config', array('name' => 'field_telephone', 'entity_type' => 'node', 'type' => 'telephone'));
     $field_storage->save();
     entity_create('field_instance_config', array('field_storage' => $field_storage, 'bundle' => 'article', 'label' => 'Telephone Number'))->save();
     entity_get_form_display('node', 'article', 'default')->setComponent('field_telephone', array('type' => 'telephone_default', 'settings' => array('placeholder' => '123-456-7890')))->save();
     entity_get_display('node', 'article', 'default')->setComponent('field_telephone', array('type' => 'telephone_link', 'weight' => 1))->save();
     // Display the article node form and verify the telephone widget is present.
     $this->drupalGet('node/add/article');
     $this->assertFieldByName("field_telephone[0][value]", '', 'Widget found.');
     // Submit an article node with a telephone field so data exist for the
     // field.
     $edit = array('title[0][value]' => $this->randomName(), 'field_telephone[0][value]' => "123456789");
     $this->drupalPostForm(NULL, $edit, t('Save'));
     $this->assertRaw('<a href="tel:123456789">');
     // Test that the module can't be uninstalled from the UI while there is data
     // for it's fields.
     $admin_user = $this->drupalCreateUser(array('access administration pages', 'administer modules'));
     $this->drupalLogin($admin_user);
     $this->drupalGet('admin/modules');
     $this->assertText('Fields type(s) in use');
     $field_storage->delete();
     $this->drupalGet('admin/modules');
     $this->assertText('Fields pending deletion');
     $this->cronRun();
     $this->assertNoText('Fields type(s) in use');
     $this->assertNoText('Fields pending deletion');
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:32,代码来源:reEnableModuleFieldTest.php


示例15: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     if ($this->profile != 'standard') {
         $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page', 'settings' => array('node' => array('options' => array('promote' => FALSE), 'submitted' => FALSE))));
         $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
     }
     $this->admin_user = $this->drupalCreateUser(array('administer nodes', 'bypass node access', 'administer content types', 'administer xmlsitemap', 'administer taxonomy'));
     $this->normal_user = $this->drupalCreateUser(array('create page content', 'edit any page content', 'access content', 'view own unpublished content'));
     // allow anonymous user to view user profiles
     $user_role = entity_load('user_role', DRUPAL_ANONYMOUS_RID);
     $user_role->grantPermission('access content');
     $user_role->save();
     xmlsitemap_link_bundle_enable('node', 'article');
     xmlsitemap_link_bundle_enable('node', 'page');
     $this->config->set('xmlsitemap_entity_taxonomy_vocabulary', 1);
     $this->config->set('xmlsitemap_entity_taxonomy_term', 1);
     $this->config->save();
     xmlsitemap_link_bundle_settings_save('node', 'page', array('status' => 1, 'priority' => 0.6, 'changefreq' => XMLSITEMAP_FREQUENCY_WEEKLY));
     // Add a vocabulary so we can test different view modes.
     $vocabulary = entity_create('taxonomy_vocabulary', array('name' => 'Tags', 'description' => $this->randomMachineName(), 'vid' => 'tags', 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'help' => ''));
     $vocabulary->save();
     xmlsitemap_link_bundle_enable('taxonomy_term', 'tags');
     // Set up a field and instance.
     $field_name = 'tags';
     entity_create('field_storage_config', array('name' => $field_name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', 'settings' => array('allowed_values' => array(array('vocabulary' => $vocabulary->vid, 'parent' => '0'))), 'cardinality' => '-1'))->save();
     entity_create('field_instance_config', array('field_name' => $field_name, 'entity_type' => 'node', 'bundle' => 'page'))->save();
     entity_get_form_display('node', 'page', 'default')->setComponent($field_name, array('type' => 'taxonomy_autocomplete'))->save();
     // Show on default display and teaser.
     entity_get_display('node', 'page', 'default')->setComponent($field_name, array('type' => 'taxonomy_term_reference_link'))->save();
     entity_get_display('node', 'page', 'teaser')->setComponent($field_name, array('type' => 'taxonomy_term_reference_link'))->save();
 }
开发者ID:jeroenos,项目名称:jeroenos_d8.mypressonline.com,代码行数:35,代码来源:XmlSitemapNodeFunctionalTest.php


示例16: testSummaryLength

 /**
  * Tests the node summary length functionality.
  */
 public function testSummaryLength()
 {
     /** @var \Drupal\Core\Render\RendererInterface $renderer */
     $renderer = $this->container->get('renderer');
     // Create a node to view.
     $settings = array('body' => array(array('value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vitae arcu at leo cursus laoreet. Curabitur dui tortor, adipiscing malesuada tempor in, bibendum ac diam. Cras non tellus a libero pellentesque condimentum. What is a Drupalism? Suspendisse ac lacus libero. Ut non est vel nisl faucibus interdum nec sed leo. Pellentesque sem risus, vulputate eu semper eget, auctor in libero. Ut fermentum est vitae metus convallis scelerisque. Phasellus pellentesque rhoncus tellus, eu dignissim purus posuere id. Quisque eu fringilla ligula. Morbi ullamcorper, lorem et mattis egestas, tortor neque pretium velit, eget eleifend odio turpis eu purus. Donec vitae metus quis leo pretium tincidunt a pulvinar sem. Morbi adipiscing laoreet mauris vel placerat. Nullam elementum, nisl sit amet scelerisque malesuada, dolor nunc hendrerit quam, eu ultrices erat est in orci. Curabitur feugiat egestas nisl sed accumsan.')), 'promote' => 1);
     $node = $this->drupalCreateNode($settings);
     $this->assertTrue(Node::load($node->id()), 'Node created.');
     // Render the node as a teaser.
     $content = $this->drupalBuildEntityView($node, 'teaser');
     $this->assertTrue(strlen($content['body'][0]['#markup']) < 600, 'Teaser is less than 600 characters long.');
     $this->setRawContent($renderer->renderRoot($content));
     // The string 'What is a Drupalism?' is between the 200th and 600th
     // characters of the node body, so it should be included if the summary is
     // 600 characters long.
     $expected = 'What is a Drupalism?';
     $this->assertRaw($expected);
     // Change the teaser length for "Basic page" content type.
     $display = entity_get_display('node', $node->getType(), 'teaser');
     $display_options = $display->getComponent('body');
     $display_options['settings']['trim_length'] = 200;
     $display->setComponent('body', $display_options)->save();
     // Render the node as a teaser again and check that the summary is now only
     // 200 characters in length and so does not include 'What is a Drupalism?'.
     $content = $this->drupalBuildEntityView($node, 'teaser');
     $this->assertTrue(strlen($content['body'][0]['#markup']) < 200, 'Teaser is less than 200 characters long.');
     $this->setRawContent($renderer->renderRoot($content));
     $this->assertText($node->label());
     $this->assertNoRaw($expected);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:33,代码来源:SummaryLengthTest.php


示例17: setUpTermReferenceField

 /**
  * Adds term reference field for the article content type.
  */
 protected function setUpTermReferenceField()
 {
     entity_create('field_storage_config', array('field_name' => $this->termFieldName, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, 'settings' => array('allowed_values' => array(array('vocabulary' => $this->vocabulary->id(), 'parent' => 0)))))->save();
     $field = entity_create('field_config', array('field_name' => $this->termFieldName, 'bundle' => 'article', 'entity_type' => 'node', 'translatable' => FALSE));
     $field->save();
     entity_get_form_display('node', 'article', 'default')->setComponent($this->termFieldName, array('type' => 'taxonomy_autocomplete'))->save();
     entity_get_display('node', 'article', 'default')->setComponent($this->termFieldName, array('type' => 'taxonomy_term_reference_link'))->save();
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:11,代码来源:TaxonomyTranslationTestTrait.php


示例18: testUserPictureEntityDisplay

 /**
  * Tests the Drupal 6 user picture to Drupal 8 entity display migration.
  */
 public function testUserPictureEntityDisplay()
 {
     $display = entity_get_display('user', 'user', 'default');
     $component = $display->getComponent('user_picture');
     $this->assertIdentical('image', $component['type']);
     $this->assertIdentical('content', $component['settings']['image_link']);
     $this->assertIdentical(array('user', 'user', 'default', 'user_picture'), entity_load('migration', 'd6_user_picture_entity_display')->getIdMap()->lookupDestinationID(array('')));
 }
开发者ID:dev981,项目名称:gaptest,代码行数:11,代码来源:MigrateUserPictureEntityDisplayTest.php


示例19: testVocabularyEntityDisplay

 /**
  * Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
  */
 public function testVocabularyEntityDisplay()
 {
     // Test that the field exists.
     $component = entity_get_display('node', 'page', 'default')->getComponent('tags');
     $this->assertIdentical('entity_reference_label', $component['type']);
     $this->assertIdentical(20, $component['weight']);
     // Test the Id map.
     $this->assertIdentical(array('node', 'article', 'default', 'tags'), entity_load('migration', 'd6_vocabulary_entity_display')->getIdMap()->lookupDestinationID(array(4, 'article')));
 }
开发者ID:scratch,项目名称:gai,代码行数:12,代码来源:MigrateVocabularyEntityDisplayTest.php


示例20: createImageField

 /**
  * Create a new image field.
  *
  * @param string $name
  *   The name of the new field (all lowercase), exclude the "field_" prefix.
  * @param string $type_name
  *   The node type that this field will be added to.
  * @param array $storage_settings
  *   A list of field storage settings that will be added to the defaults.
  * @param array $field_settings
  *   A list of instance settings that will be added to the instance defaults.
  * @param array $widget_settings
  *   A list of widget settings that will be added to the widget defaults.
  */
 function createImageField($name, $type_name, $storage_settings = array(), $field_settings = array(), $widget_settings = array())
 {
     entity_create('field_storage_config', array('field_name' => $name, 'entity_type' => 'node', 'type' => 'image', 'settings' => $storage_settings, 'cardinality' => !empty($storage_settings['cardinality']) ? $storage_settings['cardinality'] : 1))->save();
     $field_config = entity_create('field_config', array('field_name' => $name, 'label' => $name, 'entity_type' => 'node', 'bundle' => $type_name, 'required' => !empty($field_settings['required']), 'settings' => $field_settings));
     $field_config->save();
     entity_get_form_display('node', $type_name, 'default')->setComponent($name, array('type' => 'image_image', 'settings' => $widget_settings))->save();
     entity_get_display('node', $type_name, 'default')->setComponent($name)->save();
     return $field_config;
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:23,代码来源:ImageFieldTestBase.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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