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


PHP Editor::create方法代码示例

本文整理汇总了PHP中Drupal\editor\Entity\Editor::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Editor::create方法的具体用法?PHP Editor::create怎么用?PHP Editor::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\editor\Entity\Editor的用法示例。


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

示例1: testEditorImageDialogAccess

 /**
  * Test access to the editor image dialog.
  */
 public function testEditorImageDialogAccess()
 {
     $url = Url::fromRoute('editor.image_dialog', ['editor' => 'plain_text']);
     $session = $this->assertSession();
     // With no text editor, expect a 404.
     $this->drupalGet($url);
     $session->statusCodeEquals(404);
     // With a text editor but without image upload settings, expect a 200, but
     // there should not be an input[type=file].
     $editor = Editor::create(['editor' => 'ckeditor', 'format' => 'plain_text', 'settings' => ['toolbar' => ['rows' => [[['name' => 'Media', 'items' => ['DrupalImage']]]]], 'plugins' => []], 'image_upload' => ['status' => FALSE, 'scheme' => 'public', 'directory' => 'inline-images', 'max_size' => '', 'max_dimensions' => ['width' => 0, 'height' => 0]]]);
     $editor->save();
     $this->resetAll();
     $this->drupalGet($url);
     $this->assertTrue($this->cssSelect('input[type=text][name="attributes[src]"]'), 'Image uploads disabled: input[type=text][name="attributes[src]"] is present.');
     $this->assertFalse($this->cssSelect('input[type=file]'), 'Image uploads disabled: input[type=file] is absent.');
     $session->statusCodeEquals(200);
     // With image upload settings, expect a 200, and now there should be an
     // input[type=file].
     $editor->setImageUploadSettings(['status' => TRUE] + $editor->getImageUploadSettings())->save();
     $this->resetAll();
     $this->drupalGet($url);
     $this->assertFalse($this->cssSelect('input[type=text][name="attributes[src]"]'), 'Image uploads enabled: input[type=text][name="attributes[src]"] is absent.');
     $this->assertTrue($this->cssSelect('input[type=file]'), 'Image uploads enabled: input[type=file] is present.');
     $session->statusCodeEquals(200);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:28,代码来源:EditorDialogAccessTest.php

示例2: testEntityEmbedButtonMarkup

 /**
  * Tests the entity embed button markup.
  */
 public function testEntityEmbedButtonMarkup()
 {
     // Ensure that the route is not accessible with text format without the
     // button configured.
     $this->getEmbedDialog('plain_text', 'node');
     $this->assertResponse(404, 'Embed dialog is not accessible with a filter that does not have an editor configuration.');
     // Add an empty configuration for the plain_text editor configuration.
     $editor = Editor::create(['format' => 'plain_text', 'editor' => 'ckeditor']);
     $editor->save();
     $this->getEmbedDialog('plain_text', 'node');
     $this->assertResponse(403, 'Embed dialog is not accessible with a filter that does not have the embed button assigned to it.');
     // Ensure that the route is accessible with a valid embed button.
     // 'Node' embed button is provided by default by the module and hence the
     // request must be successful.
     $this->getEmbedDialog('custom_format', 'node');
     $this->assertResponse(200, 'Embed dialog is accessible with correct filter format and embed button.');
     // Ensure form structure of the 'select' step and submit form.
     $this->assertFieldByName('attributes[data-entity-id]', '', 'Entity ID/UUID field is present.');
     // Check that 'Next' is a primary button.
     $this->assertFieldByXPath('//input[contains(@class, "button--primary")]', 'Next', 'Next is a primary button');
     $title = $this->node->getTitle() . ' (' . $this->node->id() . ')';
     $edit = ['attributes[data-entity-id]' => $title];
     $this->drupalPostAjaxForm(NULL, $edit, 'op');
     /*$this->drupalPostForm(NULL, $edit, 'Next');
         // Ensure form structure of the 'embed' step and submit form.
         $this->assertFieldByName('attributes[data-entity-embed-display]', 'Entity Embed Display plugin field is present.');
     
         // Check that 'Embed' is a primary button.
         $this->assertFieldByXPath('//input[contains(@class, "button--primary")]', 'Embed', 'Embed is a primary button');*/
 }
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:33,代码来源:EntityEmbedDialogTest.php

示例3: testCommentForm_2698811

    /**
     * Ensure comment form works with history and big_pipe modules.
     *
     * @see https://www.drupal.org/node/2698811
     */
    public function testCommentForm_2698811()
    {
        $this->assertTrue($this->container->get('module_installer')->install(['comment', 'history', 'ckeditor'], TRUE), 'Installed modules.');
        // Ensure an `article` node type exists.
        $this->createContentType(['type' => 'article']);
        $this->addDefaultCommentField('node', 'article');
        // Enable CKEditor.
        $format = $this->randomMachineName();
        FilterFormat::create(['format' => $format, 'name' => $this->randomString(), 'weight' => 1, 'filters' => []])->save();
        $settings['toolbar']['rows'] = [[['name' => 'Links', 'items' => ['DrupalLink', 'DrupalUnlink']]]];
        $editor = Editor::create(['format' => $format, 'editor' => 'ckeditor']);
        $editor->setSettings($settings);
        $editor->save();
        $admin_user = $this->drupalCreateUser(['access comments', 'post comments', 'use text format ' . $format]);
        $this->drupalLogin($admin_user);
        $node = $this->createNode(['type' => 'article', 'comment' => CommentItemInterface::OPEN]);
        // Create some comments.
        foreach (range(1, 5) as $i) {
            $comment = Comment::create(['status' => CommentInterface::PUBLISHED, 'field_name' => 'comment', 'entity_type' => 'node', 'entity_id' => $node->id()]);
            $comment->save();
        }
        $this->drupalGet($node->toUrl()->toString());
        // Confirm that CKEditor loaded.
        $javascript = <<<JS
    (function(){
      return Object.keys(CKEDITOR.instances).length > 0;
    }());
JS;
        $this->assertJsCondition($javascript);
    }
开发者ID:DrupalCamp-NYC,项目名称:dcnyc16,代码行数:35,代码来源:BigPipeRegressionTest.php

示例4: testManager

 /**
  * Tests the configurable text editor manager.
  */
 public function testManager()
 {
     $this->editorManager = $this->container->get('plugin.manager.editor');
     // Case 1: no text editor available:
     // - listOptions() should return an empty list of options
     // - getAttachments() should return an empty #attachments array (and not
     //   a JS settings structure that is empty)
     $this->assertIdentical(array(), $this->editorManager->listOptions(), 'When no text editor is enabled, the manager works correctly.');
     $this->assertIdentical(array(), $this->editorManager->getAttachments(array()), 'No attachments when no text editor is enabled and retrieving attachments for zero text formats.');
     $this->assertIdentical(array(), $this->editorManager->getAttachments(array('filtered_html', 'full_html')), 'No attachments when no text editor is enabled and retrieving attachments for multiple text formats.');
     // Enable the Text Editor Test module, which has the Unicorn Editor and
     // clear the editor manager's cache so it is picked up.
     $this->enableModules(array('editor_test'));
     $this->editorManager = $this->container->get('plugin.manager.editor');
     $this->editorManager->clearCachedDefinitions();
     // Case 2: a text editor available.
     $this->assertIdentical('Unicorn Editor', (string) $this->editorManager->listOptions()['unicorn'], 'When some text editor is enabled, the manager works correctly.');
     // Case 3: a text editor available & associated (but associated only with
     // the 'Full HTML' text format).
     $unicorn_plugin = $this->editorManager->createInstance('unicorn');
     $editor = Editor::create(['format' => 'full_html', 'editor' => 'unicorn']);
     $editor->save();
     $this->assertIdentical(array(), $this->editorManager->getAttachments(array()), 'No attachments when one text editor is enabled and retrieving attachments for zero text formats.');
     $expected = array('library' => array(0 => 'editor_test/unicorn'), 'drupalSettings' => ['editor' => ['formats' => ['full_html' => ['format' => 'full_html', 'editor' => 'unicorn', 'editorSettings' => $unicorn_plugin->getJSSettings($editor), 'editorSupportsContentFiltering' => TRUE, 'isXssSafe' => FALSE]]]]);
     $this->assertIdentical($expected, $this->editorManager->getAttachments(array('filtered_html', 'full_html')), 'Correct attachments when one text editor is enabled and retrieving attachments for multiple text formats.');
     // Case 4: a text editor available associated, but now with its JS settings
     // being altered via hook_editor_js_settings_alter().
     \Drupal::state()->set('editor_test_js_settings_alter_enabled', TRUE);
     $expected['drupalSettings']['editor']['formats']['full_html']['editorSettings']['ponyModeEnabled'] = FALSE;
     $this->assertIdentical($expected, $this->editorManager->getAttachments(array('filtered_html', 'full_html')), 'hook_editor_js_settings_alter() works correctly.');
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:34,代码来源:EditorManagerTest.php

示例5: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Create a text format and associate this with CKEditor.
     FilterFormat::create(['format' => 'full_html', 'name' => 'Full HTML', 'weight' => 1, 'filters' => []])->save();
     Editor::create(['format' => 'full_html', 'editor' => 'ckeditor'])->save();
     // Create a new user with admin rights.
     $this->admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages', 'administer site configuration', 'administer filters']);
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:12,代码来源:CKEditorToolbarButtonTest.php

示例6: setUp

 protected function setUp()
 {
     parent::setUp();
     // Install the Filter module.
     // Create text format, associate CKEditor.
     $filtered_html_format = FilterFormat::create(array('format' => 'filtered_html', 'name' => 'Filtered HTML', 'weight' => 0, 'filters' => array()));
     $filtered_html_format->save();
     $editor = Editor::create(['format' => 'filtered_html', 'editor' => 'ckeditor']);
     $editor->save();
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:10,代码来源:CKEditorPluginManagerTest.php

示例7: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->format = strtolower($this->randomMachineName());
     $filter_format = FilterFormat::create(['format' => $this->format, 'name' => $this->randomString(), 'filters' => []]);
     $filter_format->save();
     $editor = Editor::create(['format' => $this->format, 'editor' => 'ckeditor']);
     $editor->save();
     $this->adminUser = $this->drupalCreateUser(['administer filters']);
 }
开发者ID:DrupalCamp-NYC,项目名称:dcnyc16,代码行数:13,代码来源:CKEditorStylesComboAdminTest.php

示例8: testEmbedButtonEditorAccessCheck

 /**
  * Tests \Drupal\embed\Access\EmbedButtonEditorAccessCheck.
  */
 public function testEmbedButtonEditorAccessCheck()
 {
     // The anonymous user should have access to the plain_text format, but it
     // hasn't been configured to use an editor yet.
     $this->getRoute('plain_text', 'embed_test_default');
     $this->assertResponse(404);
     $this->assertCacheContext('route');
     $this->assertNoCacheTag('config:editor.editor.embed_test');
     $this->assertNoCacheTag('config:embed.button.embed_test_default');
     // The anonymous user should not have permission to use embed_test format.
     $this->getRoute('embed_test', 'embed_test_default');
     $this->assertResponse(403);
     $this->assertCacheContext('route');
     $this->assertNoCacheTag('config:editor.editor.embed_test');
     $this->assertNoCacheTag('config:embed.button.embed_test_default');
     // Now login a user that can use the embed_test format.
     $this->drupalLogin($this->webUser);
     $this->getRoute('plain_text', 'embed_test_default');
     $this->assertResponse(404);
     $this->assertCacheContext('route');
     $this->assertNoCacheTag('config:editor.editor.plain_text');
     $this->assertNoCacheTag('config:embed.button.embed_test_default');
     // Add an empty configuration for the plain_text editor configuration.
     $editor = Editor::create(['format' => 'plain_text', 'editor' => 'ckeditor']);
     $editor->save();
     $this->getRoute('plain_text', 'embed_test_default');
     $this->assertResponse(403);
     $this->assertCacheContext('route');
     $this->assertCacheTag('config:editor.editor.plain_text');
     $this->assertCacheTag('config:embed.button.embed_test_default');
     $this->getRoute('embed_test', 'embed_test_default');
     $this->assertResponse(200);
     $this->assertCacheContext('route');
     $this->assertCacheTag('config:editor.editor.embed_test');
     $this->assertCacheTag('config:embed.button.embed_test_default');
     $this->assertText(static::SUCCESS);
     // Test route with an empty request.
     $this->getRoute('embed_test', 'embed_test_default', '');
     $this->assertResponse(404);
     $this->assertCacheContext('route');
     $this->assertCacheTag('config:editor.editor.embed_test');
     $this->assertCacheTag('config:embed.button.embed_test_default');
     // Test route with an invalid text format.
     $this->getRoute('invalid_editor', 'embed_test_default');
     $this->assertResponse(404);
     $this->assertCacheContext('route');
     $this->assertNoCacheTag('config:editor.editor.invalid_editor');
     $this->assertNoCacheTag('config:embed.button.embed_test_default');
     // Test route with an invalid embed button.
     $this->getRoute('embed_test', 'invalid_button');
     $this->assertResponse(404);
     $this->assertCacheContext('route');
     $this->assertNoCacheTag('config:editor.editor.embed_test');
     $this->assertNoCacheTag('config:embed.button.invalid_button');
 }
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:58,代码来源:EmbedButtonEditorAccessCheckTest.php

示例9: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('editor');
     $this->installEntitySchema('filter_format');
     $this->format = FilterFormat::create(['format' => 'test_format', 'name' => $this->randomMachineName()]);
     $this->format->save();
     $this->editor = Editor::create(['editor' => 'ckeditor', 'format' => 'test_format', 'settings' => ['toolbar' => ['rows' => [[['name' => 'Enabled Buttons', 'items' => ['Format']]]]]]]);
     $this->editor->save();
     $this->ckeditorPluginManager = $this->container->get('plugin.manager.ckeditor.plugin');
 }
开发者ID:Greg-Boggs,项目名称:electric-dev,代码行数:14,代码来源:InternalTest.php

示例10: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Add text format.
     FilterFormat::create(['format' => 'basic_html', 'name' => 'Basic HTML', 'weight' => 0])->save();
     // Set up text editor.
     Editor::create(['format' => 'basic_html', 'editor' => 'unicorn', 'image_upload' => ['status' => TRUE, 'scheme' => 'public', 'directory' => 'inline-images', 'max_size' => '', 'max_dimensions' => ['width' => NULL, 'height' => NULL]]])->save();
     // Create admin user.
     $this->adminUser = $this->drupalCreateUser(['administer filters', 'use text format basic_html']);
     $this->drupalLogin($this->adminUser);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:14,代码来源:EditorUploadImageScaleTest.php

示例11: setUp

 protected function setUp()
 {
     parent::setUp();
     // Install the Filter module.
     // Create text format, associate CKEditor.
     $filtered_html_format = FilterFormat::create(array('format' => 'filtered_html', 'name' => 'Filtered HTML', 'weight' => 0, 'filters' => array('filter_html' => array('status' => 1, 'settings' => array('allowed_html' => '<h2 id> <h3> <h4> <h5> <h6> <p> <br> <strong> <a href hreflang>')))));
     $filtered_html_format->save();
     $editor = Editor::create(['format' => 'filtered_html', 'editor' => 'ckeditor']);
     $editor->save();
     // Create "CKEditor" text editor plugin instance.
     $this->ckeditor = $this->container->get('plugin.manager.editor')->createInstance('ckeditor');
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:12,代码来源:CKEditorTest.php

示例12: setUp

 protected function setUp()
 {
     parent::setUp();
     // Install the Filter module.
     // Create a field.
     $this->fieldName = 'field_textarea';
     $this->createFieldWithStorage($this->fieldName, 'text', 1, 'Long text field', array(), 'text_textarea', array('size' => 42), 'text_default', array());
     // Create text format.
     $full_html_format = FilterFormat::create(array('format' => 'full_html', 'name' => 'Full HTML', 'weight' => 1, 'filters' => array()));
     $full_html_format->save();
     // Associate text editor with text format.
     $editor = Editor::create(['format' => $full_html_format->id(), 'editor' => 'unicorn']);
     $editor->save();
     // Also create a text format without an associated text editor.
     FilterFormat::create(array('format' => 'no_editor', 'name' => 'No Text Editor', 'weight' => 2, 'filters' => array()))->save();
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:16,代码来源:QuickEditIntegrationTest.php

示例13: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create text format, associate CKEditor.
     $filtered_html_format = FilterFormat::create(array('format' => 'filtered_html', 'name' => 'Filtered HTML', 'weight' => 0, 'filters' => array()));
     $filtered_html_format->save();
     $editor = Editor::create(['format' => 'filtered_html', 'editor' => 'ckeditor']);
     $editor->save();
     // Create a second format without an associated editor so a drop down select
     // list is created when selecting formats.
     $full_html_format = FilterFormat::create(array('format' => 'full_html', 'name' => 'Full HTML', 'weight' => 1, 'filters' => array()));
     $full_html_format->save();
     // Create node type.
     $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
     $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', 'use text format full_html'));
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:17,代码来源:CKEditorLoadingTest.php

示例14: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Create Filtered HTML text format and enable entity_embed filter.
     $format = FilterFormat::create(['format' => 'embed_test', 'name' => 'Embed format', 'filters' => []]);
     $format->save();
     $editor_group = ['name' => 'Embed', 'items' => ['embed_test_default']];
     $editor = Editor::create(['format' => 'embed_test', 'editor' => 'ckeditor', 'settings' => ['toolbar' => ['rows' => [[$editor_group]]]]]);
     $editor->save();
     // Create a user with required permissions.
     $this->adminUser = $this->drupalCreateUser(['administer embed buttons', 'use text format embed_test']);
     // Create a user with required permissions.
     $this->webUser = $this->drupalCreateUser(['use text format embed_test']);
     // Set up some standard blocks for the testing theme (Classy).
     // @see https://www.drupal.org/node/507488?page=1#comment-10291517
     $this->drupalPlaceBlock('local_tasks_block');
     $this->drupalPlaceBlock('local_actions_block');
 }
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:21,代码来源:EmbedTestBase.php

示例15: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('file');
     $this->installSchema('node', array('node_access'));
     $this->installSchema('file', array('file_usage'));
     $this->installConfig(['node']);
     // Add text formats.
     $filtered_html_format = FilterFormat::create(array('format' => 'filtered_html', 'name' => 'Filtered HTML', 'weight' => 0, 'filters' => array()));
     $filtered_html_format->save();
     // Set cardinality for body field.
     FieldStorageConfig::loadByName('node', 'body')->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)->save();
     // Set up text editor.
     $editor = Editor::create(['format' => 'filtered_html', 'editor' => 'unicorn']);
     $editor->save();
     // Create a node type for testing.
     $type = NodeType::create(['type' => 'page', 'name' => 'page']);
     $type->save();
     node_add_body_field($type);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:20,代码来源:EditorFileUsageTest.php


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