本文整理汇总了PHP中entity_get_form_display函数的典型用法代码示例。如果您正苦于以下问题:PHP entity_get_form_display函数的具体用法?PHP entity_get_form_display怎么用?PHP entity_get_form_display使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了entity_get_form_display函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getMatches
/**
* Returns matched labels based on a given field, instance and search string.
*
* This function can be used by other modules that wish to pass a mocked
* definition of the field on instance.
*
* @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
* The field definition.
* @param string $entity_type
* The entity type.
* @param string $bundle
* The entity bundle.
* @param string $entity_id
* (optional) The entity ID the entity reference field is attached to.
* Defaults to ''.
* @param string $prefix
* (optional) A prefix for all the keys returned by this function.
* @param string $string
* (optional) The label of the entity to query by.
*
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
* Thrown when the current user doesn't have access to the specifies entity.
*
* @return array
* A list of matched entity labels.
*
* @see \Drupal\entity_reference\EntityReferenceController
*/
public function getMatches(FieldDefinitionInterface $field_definition, $entity_type, $bundle, $entity_id = '', $prefix = '', $string = '')
{
$matches = array();
$entity = NULL;
if ($entity_id !== 'NULL') {
$entity = $this->entityManager->getStorage($entity_type)->load($entity_id);
if (!$entity || !$entity->access('view')) {
throw new AccessDeniedHttpException();
}
}
$handler = $this->selectionHandlerManager->getSelectionHandler($field_definition, $entity);
if (isset($string)) {
// Get an array of matching entities.
$widget = entity_get_form_display($entity_type, $bundle, 'default')->getComponent($field_definition->getName());
$match_operator = !empty($widget['settings']['match_operator']) ? $widget['settings']['match_operator'] : 'CONTAINS';
$entity_labels = $handler->getReferenceableEntities($string, $match_operator, 10);
// Loop through the entities and convert them into autocomplete output.
foreach ($entity_labels as $values) {
foreach ($values as $entity_id => $label) {
$key = "{$label} ({$entity_id})";
// Strip things like starting/trailing white spaces, line breaks and
// tags.
$key = preg_replace('/\\s\\s+/', ' ', str_replace("\n", '', trim(decode_entities(strip_tags($key)))));
// Names containing commas or quotes must be wrapped in quotes.
$key = Tags::encode($key);
$matches[] = array('value' => $prefix . $key, 'label' => $label);
}
}
}
return $matches;
}
开发者ID:anatalsceo,项目名称:en-classe,代码行数:59,代码来源:EntityReferenceAutocomplete.php
示例2: 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
示例3: setUp
protected function setUp()
{
parent::setUp();
// Set up an additional language.
$this->langcodes = array(language_default()->getId(), 'es');
ConfigurableLanguage::createFromLangcode('es')->save();
// Create a content type.
$this->bundle = $this->randomMachineName();
$this->contentType = $this->drupalCreateContentType(array('type' => $this->bundle));
// Enable translation for the current entity type and ensure the change is
// picked up.
content_translation_set_config('node', $this->bundle, 'enabled', TRUE);
drupal_static_reset();
\Drupal::entityManager()->clearCachedBundles();
\Drupal::service('router.builder')->rebuild();
// Add a translatable field to the content type.
entity_create('field_storage_config', array('field_name' => 'field_test_text', 'entity_type' => 'node', 'type' => 'text', 'cardinality' => 1, 'translatable' => TRUE))->save();
entity_create('field_config', array('entity_type' => 'node', 'field_name' => 'field_test_text', 'bundle' => $this->bundle, 'label' => 'Test text-field'))->save();
entity_get_form_display('node', $this->bundle, 'default')->setComponent('field_test_text', array('type' => 'text_textfield', 'weight' => 0))->save();
// Enable content translation.
$configuration = array('langcode' => language_default()->getId(), 'language_show' => TRUE);
language_save_default_configuration('node', $this->bundle, $configuration);
// Create a translator user.
$permissions = array('access contextual links', 'administer nodes', "edit any {$this->bundle} content", 'translate any entity');
$this->translator = $this->drupalCreateUser($permissions);
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:26,代码来源:ContentTranslationContextualLinksTest.php
示例4: 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
示例5: testVideo
/**
* Test ID validation and the proper video display of a valid ID.
*/
public 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 that 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:aakb,项目名称:cfia,代码行数:37,代码来源:YouTubeTest.php
示例6: _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
示例7: 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
示例8: setUp
protected function setUp()
{
parent::setUp();
// Let there be T-rex.
\Drupal::state()->set('editor_test_give_me_a_trex_thanks', TRUE);
\Drupal::service('plugin.manager.editor')->clearCachedDefinitions();
// Add text formats.
$filtered_html_format = entity_create('filter_format', array('format' => 'filtered_html', 'name' => 'Filtered HTML', 'weight' => 0, 'filters' => array()));
$filtered_html_format->save();
$full_html_format = entity_create('filter_format', array('format' => 'full_html', 'name' => 'Full HTML', 'weight' => 1, 'filters' => array()));
$full_html_format->save();
// Create article node type.
$this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
// Create page node type, but remove the body.
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Page'));
$body = FieldConfig::loadByName('node', 'page', 'body');
$body->delete();
// Create a formatted text field, which uses an <input type="text">.
FieldStorageConfig::create(array('field_name' => 'field_text', 'entity_type' => 'node', 'type' => 'text'))->save();
FieldConfig::create(array('field_name' => 'field_text', 'entity_type' => 'node', 'label' => 'Textfield', 'bundle' => 'page'))->save();
entity_get_form_display('node', 'page', 'default')->setComponent('field_text')->save();
// Create 3 users, each with access to different text formats.
$this->untrustedUser = $this->drupalCreateUser(array('create article content', 'edit any article content'));
$this->normalUser = $this->drupalCreateUser(array('create article content', 'edit any article content', 'use text format filtered_html'));
$this->privilegedUser = $this->drupalCreateUser(array('create article content', 'edit any article content', 'create page content', 'edit any page content', 'use text format filtered_html', 'use text format full_html'));
}
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:26,代码来源:EditorLoadingTest.php
示例9: testEntityFormDisplaySettings
/**
* Tests the field's entity form display settings.
*/
public function testEntityFormDisplaySettings()
{
$component = entity_get_form_display('user', 'user', 'default')->getComponent('user_picture');
$this->assertIdentical('image_image', $component['type']);
$this->assertIdentical('throbber', $component['settings']['progress_indicator']);
$this->assertIdentical('thumbnail', $component['settings']['preview_image_style']);
}
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:10,代码来源:MigrateUserPictureEntityFormDisplayTest.php
示例10: 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
示例11: initNode
/**
* Setup a new content type, with a image/file field.
*/
protected function initNode()
{
// Create a new content type.
$this->drupalCreateContentType(array('type' => $this->instBundle, 'name' => $this->instBundle));
// Prep a field base.
$field_storage_settings = array('display_field' => TRUE, 'display_default' => TRUE, 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
$field_storage = array('entity_type' => 'node', 'field_name' => $this->instFieldName, 'type' => $this->instFieldType, 'settings' => $field_storage_settings, 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
entity_create('field_storage_config', $field_storage)->save();
// Prep a field instance.
$field_settings = array();
if ($this->instFieldType == 'image') {
$field_settings['alt_field'] = TRUE;
$field_settings['alt_field_required'] = FALSE;
$field_settings['title_field'] = TRUE;
$field_settings['title_field_required'] = FALSE;
}
if ($this->instFieldType == 'file') {
$field_settings['description_field'] = TRUE;
$field_settings['file_extensions'] = 'txt jpg png mp3 rtf docx pdf';
}
$field = array('field_name' => $this->instFieldName, 'label' => $this->randomString(), 'entity_type' => 'node', 'bundle' => $this->instBundle, 'required' => FALSE, 'settings' => $field_settings);
entity_create('field_config', $field)->save();
// Setup widget.
entity_get_form_display('node', $this->instBundle, 'default')->setComponent($this->instFieldName, array('type' => 'file_generic', 'settings' => array()))->save();
// Clear some caches for good measure.
$entity_manager = $this->container->get('entity.manager');
$entity_manager->getStorage('field_storage_config')->resetCache();
$entity_manager->getStorage('field_config')->resetCache();
}
开发者ID:rafavergara,项目名称:ddv8,代码行数:32,代码来源:JuiceboxBaseCase.php
示例12: testPreserveFormActionAfterAJAX
/**
* Tests that a form's action is retained after an Ajax submission.
*
* The 'action' attribute of a form should not change after an Ajax submission
* followed by a non-Ajax submission, which triggers a validation error.
*/
function testPreserveFormActionAfterAJAX()
{
// Create a multi-valued field for 'page' nodes to use for Ajax testing.
$field_name = 'field_ajax_test';
FieldStorageConfig::create(array('field_name' => $field_name, 'entity_type' => 'node', 'type' => 'text', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED))->save();
FieldConfig::create(['field_name' => $field_name, 'entity_type' => 'node', 'bundle' => 'page'])->save();
entity_get_form_display('node', 'page', 'default')->setComponent($field_name, array('type' => 'text_textfield'))->save();
// Log in a user who can create 'page' nodes.
$this->webUser = $this->drupalCreateUser(array('create page content'));
$this->drupalLogin($this->webUser);
// Get the form for adding a 'page' node. Submit an "add another item" Ajax
// submission and verify it worked by ensuring the updated page has two text
// field items in the field for which we just added an item.
$this->drupalGet('node/add/page');
$this->drupalPostAjaxForm(NULL, array(), array('field_ajax_test_add_more' => t('Add another item')), NULL, array(), array(), 'node-page-form');
$this->assert(count($this->xpath('//div[contains(@class, "field--name-field-ajax-test")]//input[@type="text"]')) == 2, 'AJAX submission succeeded.');
// Submit the form with the non-Ajax "Save" button, leaving the title field
// blank to trigger a validation error, and ensure that a validation error
// occurred, because this test is for testing what happens when a form is
// re-rendered without being re-built, which is what happens when there's
// a validation error.
$this->drupalPostForm(NULL, array(), t('Save'));
$this->assertText('Title field is required.', 'Non-AJAX submission correctly triggered a validation error.');
// Ensure that the form contains two items in the multi-valued field, so we
// know we're testing a form that was correctly retrieved from cache.
$this->assert(count($this->xpath('//form[contains(@id, "node-page-form")]//div[contains(@class, "js-form-item-field-ajax-test")]//input[@type="text"]')) == 2, 'Form retained its state from cache.');
// Ensure that the form's action is correct.
$forms = $this->xpath('//form[contains(@class, "node-page-form")]');
$this->assertEqual(1, count($forms));
// Strip query params off the action before asserting.
$url = parse_url($forms[0]['action'])['path'];
$this->assertEqual(Url::fromRoute('node.add', ['node_type' => 'page'])->toString(), $url);
}
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:39,代码来源:RebuildTest.php
示例13: setUp
protected function setUp()
{
parent::setUp();
$this->addDefaultCommentField('node', 'page');
$web_user = $this->drupalCreateUser(array('edit own page content', 'create page content'));
$this->drupalLogin($web_user);
// Add a vocabulary so we can test different view modes.
$vocabulary = entity_create('taxonomy_vocabulary', array('name' => $this->randomMachineName(), 'description' => $this->randomMachineName(), 'vid' => $this->randomMachineName(), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'help' => ''));
$vocabulary->save();
$this->vocabulary = $vocabulary;
// Add a term to the vocabulary.
$term = entity_create('taxonomy_term', array('name' => $this->randomMachineName(), 'description' => $this->randomMachineName(), 'vid' => $this->vocabulary->id(), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
$term->save();
$this->term = $term;
// Create an image field.
FieldStorageConfig::create(['field_name' => 'field_image', 'entity_type' => 'node', 'type' => 'image', 'settings' => [], 'cardinality' => FieldStorageConfig::CARDINALITY_UNLIMITED])->save();
$field_config = FieldConfig::create(['field_name' => 'field_image', 'label' => 'Images', 'entity_type' => 'node', 'bundle' => 'page', 'required' => FALSE, 'settings' => []]);
$field_config->save();
// Create a field.
$this->fieldName = Unicode::strtolower($this->randomMachineName());
$handler_settings = array('target_bundles' => array($this->vocabulary->id() => $this->vocabulary->id()), 'auto_create' => TRUE);
$this->createEntityReferenceField('node', 'page', $this->fieldName, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
entity_get_form_display('node', 'page', 'default')->setComponent($this->fieldName, array('type' => 'entity_reference_autocomplete_tags'))->save();
// Show on default display and teaser.
entity_get_display('node', 'page', 'default')->setComponent($this->fieldName, array('type' => 'entity_reference_label'))->save();
entity_get_display('node', 'page', 'teaser')->setComponent($this->fieldName, array('type' => 'entity_reference_label'))->save();
entity_get_form_display('node', 'page', 'default')->setComponent('field_image', array('type' => 'image_image', 'settings' => []))->save();
entity_get_display('node', 'page', 'default')->setComponent('field_image')->save();
}
开发者ID:ddrozdik,项目名称:dmaps,代码行数:29,代码来源:PagePreviewTest.php
示例14: 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
示例15: testCommentEntityFormDisplay
/**
* Tests comment subject variable migrated into an entity display.
*/
public function testCommentEntityFormDisplay()
{
$component = entity_get_form_display('comment', 'comment', 'default')->getComponent('subject');
$this->assertIdentical('string_textfield', $component['type']);
$this->assertIdentical(10, $component['weight']);
$component = entity_get_form_display('comment', 'comment_no_subject', 'default')->getComponent('subject');
$this->assertNull($component);
}
开发者ID:RealLukeMartin,项目名称:drupal8tester,代码行数:11,代码来源:MigrateCommentVariableEntityFormDisplaySubjectTest.php
示例16: testUserPictureEntityFormDisplay
/**
* Tests the Drupal 6 user picture to Drupal 8 entity form display migration.
*/
public function testUserPictureEntityFormDisplay()
{
$display = entity_get_form_display('user', 'user', 'default');
$component = $display->getComponent('user_picture');
$this->assertEqual($component['type'], 'image_image');
$this->assertEqual($component['settings']['progress_indicator'], 'throbber');
$this->assertEqual(array('user', 'user', 'default', 'user_picture'), entity_load('migration', 'd6_user_picture_entity_form_display')->getIdMap()->lookupDestinationID(array('')));
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:11,代码来源:MigrateUserPictureEntityFormDisplayTest.php
示例17: testCommentEntityFormDisplay
/**
* Tests comment subject variable migrated into an entity display.
*/
public function testCommentEntityFormDisplay()
{
$component = entity_get_form_display('comment', 'comment', 'default')->getComponent('subject');
$this->assertEqual($component['type'], 'string');
$this->assertEqual($component['weight'], 10);
$component = entity_get_form_display('comment', 'comment_no_subject', 'default')->getComponent('subject');
$this->assertNull($component);
}
开发者ID:anatalsceo,项目名称:en-classe,代码行数:11,代码来源:MigrateCommentVariableEntityFormDisplaySubjectTest.php
示例18: setUp
protected function setUp()
{
parent::setUp();
// Auto-create a field for testing.
entity_create('field_storage_config', array('entity_type' => 'user', 'field_name' => 'test_multiple', 'type' => 'text', 'cardinality' => -1, 'translatable' => FALSE))->save();
entity_create('field_config', array('entity_type' => 'user', 'field_name' => 'test_multiple', 'bundle' => 'user', 'label' => 'Test a multiple valued field'))->save();
entity_get_form_display('user', 'user', 'register')->setComponent('test_multiple', array('type' => 'text_textfield', 'weight' => 0))->save();
}
开发者ID:ddrozdik,项目名称:dmaps,代码行数:8,代码来源:ArbitraryRebuildTest.php
示例19: 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
示例20: testCommentEntityFormDisplay
/**
* Tests comment variables migrated into an entity display.
*/
public function testCommentEntityFormDisplay()
{
foreach ($this->types as $type) {
$component = entity_get_form_display('node', $type, 'default')->getComponent('comment');
$this->assertIdentical('comment_default', $component['type']);
$this->assertIdentical(20, $component['weight']);
}
}
开发者ID:dev981,项目名称:gaptest,代码行数:11,代码来源:MigrateCommentVariableEntityFormDisp |
请发表评论