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

PHP Entity\Editor类代码示例

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

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



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

示例1: isEnabled

 /**
  * {@inheritdoc}
  */
 function isEnabled(Editor $editor)
 {
     if (!$editor->hasAssociatedFilterFormat()) {
         return FALSE;
     }
     // Automatically enable this plugin if the text format associated with this
     // text editor uses the filter_align or filter_caption filter and the
     // DrupalImage button is enabled.
     $format = $editor->getFilterFormat();
     if ($format->filters('filter_align')->status || $format->filters('filter_caption')->status) {
         $enabled = FALSE;
         $settings = $editor->getSettings();
         foreach ($settings['toolbar']['rows'] as $row) {
             foreach ($row as $group) {
                 foreach ($group['items'] as $button) {
                     if ($button === 'DrupalImage') {
                         $enabled = TRUE;
                     }
                 }
             }
         }
         return $enabled;
     }
     return FALSE;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:28,代码来源:DrupalImageCaption.php


示例2: settingsForm

 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor)
 {
     $editor_settings = $editor->getSettings();
     $plugin_settings = NestedArray::getValue($editor_settings, ['plugins', 'video_embed', 'defaults', 'children']);
     $settings = $plugin_settings ?: [];
     $form['defaults'] = ['#title' => $this->t('Default Settings'), '#type' => 'fieldset', '#tree' => TRUE, 'children' => Video::mockInstance($settings)->settingsForm([], new FormState())];
     return $form;
 }
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:11,代码来源:VideoEmbedWysiwyg.php


示例3: getJSSettings

 /**
  * {@inheritdoc}
  */
 public function getJSSettings(EditorEntity $editor)
 {
     $js_settings = array();
     $settings = $editor->getSettings();
     if ($settings['stumpy_arms']) {
         $js_settings['doMyArmsLookStumpy'] = TRUE;
     }
     return $js_settings;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:12,代码来源:TRexEditor.php


示例4: getJSSettings

 /**
  * {@inheritdoc}
  */
 function getJSSettings(EditorEntity $editor)
 {
     $js_settings = array();
     $settings = $editor->getSettings();
     if ($settings['ponies too']) {
         $js_settings['ponyModeEnabled'] = TRUE;
     }
     return $js_settings;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:12,代码来源:UnicornEditor.php


示例5: settingsForm

 /**
  * Implements \Drupal\ckeditor\Plugin\CKEditorPluginConfigurableInterface::settingsForm().
  */
 public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor)
 {
     // Defaults.
     $config = array('styles' => '');
     $settings = $editor->getSettings();
     if (isset($settings['plugins']['stylescombo'])) {
         $config = $settings['plugins']['stylescombo'];
     }
     $form['styles'] = array('#title' => t('Styles'), '#title_display' => 'invisible', '#type' => 'textarea', '#default_value' => $config['styles'], '#description' => t('A list of classes that will be provided in the "Styles" dropdown. Enter one class on each line in the format: element.class|Label. Example: h1.title|Title.<br />These styles should be available in your theme\'s CSS file.'), '#attached' => array('library' => array('ckeditor/drupal.ckeditor.stylescombo.admin')), '#element_validate' => array(array($this, 'validateStylesValue')));
     return $form;
 }
开发者ID:dmyerson,项目名称:d8ecs,代码行数:14,代码来源:StylesCombo.php


示例6: settingsForm

 /**
  * Implements \Drupal\ckeditor\Plugin\CKEditorPluginConfigurableInterface::settingsForm().
  */
 function settingsForm(array $form, array &$form_state, Editor $editor)
 {
     // Defaults.
     $config = array('ultra_llama_mode' => FALSE);
     $settings = $editor->getSettings();
     if (isset($settings['plugins']['llama_contextual_and_button'])) {
         $config = $settings['plugins']['llama_contextual_and_button'];
     }
     $form['ultra_llama_mode'] = array('#title' => t('Ultra llama mode'), '#type' => 'checkbox', '#default_value' => $config['ultra_llama_mode']);
     return $form;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:14,代码来源:LlamaContextualAndButton.php


示例7: 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


示例8: settingsForm

 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor)
 {
     $settings = $editor->getSettings();
     $styles = $this->getStyles();
     $config = \Drupal::config('codesnippet.settings');
     $default_style = $config->get('style');
     $languages = $config->get('languages');
     asort($languages);
     $form['#attached']['library'][] = 'codesnippet/codesnippet.admin';
     $form['highlight_style'] = array('#type' => 'select', '#title' => 'highlight.js Style', '#description' => $this->t('Select a style to apply to all highlighted code snippets. You can preview the styles at @link.', array('@link' => \Drupal::l('https://highlightjs.org/static/demo', Url::fromUri('https://highlightjs.org/static/demo/')))), '#options' => $styles, '#default_value' => !empty($settings['plugins']['codesnippet']['highlight_style']) ? $settings['plugins']['codesnippet']['highlight_style'] : $default_style);
     $form['highlight_languages'] = array('#type' => 'checkboxes', '#title' => 'Supported Languages', '#options' => $languages, '#description' => t('Enter languages you want to have as options in the editor dialog. To add a language not in this list, please see the README.txt of this module.'), '#default_value' => $settings['plugins']['codesnippet']['highlight_languages']);
     return $form;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:16,代码来源:CodeSnippet.php


示例9: isEnabled

 /**
  * {@inheritdoc}
  */
 function isEnabled(Editor $editor)
 {
     // Automatically enable this plugin if the Underline button is enabled.
     $settings = $editor->getSettings();
     foreach ($settings['toolbar']['rows'] as $row) {
         foreach ($row as $group) {
             if (in_array('Strike', $group['items'])) {
                 return TRUE;
             }
         }
     }
     return FALSE;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:16,代码来源:LlamaContextual.php


示例10: 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


示例11: 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


示例12: testExistingFormat

 /**
  * Tests StylesCombo settings for an existing text format.
  */
 function testExistingFormat()
 {
     $ckeditor = $this->container->get('plugin.manager.editor')->createInstance('ckeditor');
     $default_settings = $ckeditor->getDefaultSettings();
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('admin/config/content/formats/manage/' . $this->format);
     // Ensure an Editor config entity exists, with the proper settings.
     $expected_settings = $default_settings;
     $editor = Editor::load($this->format);
     $this->assertEqual($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.');
     // Case 1: Configure the Styles plugin with different labels for each style,
     // and ensure the updated settings are saved.
     $this->drupalGet('admin/config/content/formats/manage/' . $this->format);
     $edit = ['editor[settings][plugins][stylescombo][styles]' => "h1.title|Title\np.callout|Callout\n\n"];
     $this->drupalPostForm(NULL, $edit, t('Save configuration'));
     $expected_settings['plugins']['stylescombo']['styles'] = "h1.title|Title\np.callout|Callout\n\n";
     $editor = Editor::load($this->format);
     $this->assertEqual($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.');
     // Case 2: Configure the Styles plugin with same labels for each style, and
     // ensure that an error is displayed and that the updated settings are not
     // saved.
     $this->drupalGet('admin/config/content/formats/manage/' . $this->format);
     $edit = ['editor[settings][plugins][stylescombo][styles]' => "h1.title|Title\np.callout|Title\n\n"];
     $this->drupalPostForm(NULL, $edit, t('Save configuration'));
     $this->assertRaw(t('Each style must have a unique label.'));
     $expected_settings['plugins']['stylescombo']['styles'] = "h1.title|Title\np.callout|Callout\n\n";
     $editor = Editor::load($this->format);
     $this->assertEqual($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.');
 }
开发者ID:DrupalCamp-NYC,项目名称:dcnyc16,代码行数:32,代码来源:CKEditorStylesComboAdminTest.php


示例13: 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


示例14: 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


示例15: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, FilterFormat $filter_format = NULL)
 {
     // Add AJAX support.
     $form['#prefix'] = '<div id="video-embed-dialog-form">';
     $form['#suffix'] = '</div>';
     // Ensure relevant dialog libraries are attached.
     $form['#attached']['library'][] = 'editor/drupal.editor.dialog';
     // Simple URL field and submit button for video URL.
     $form['video_url'] = ['#type' => 'textfield', '#title' => $this->t('Video URL'), '#required' => TRUE, '#default_value' => $this->getUserInput($form_state, 'video_url')];
     // If no settings are found, use the defaults configured in the filter
     // formats interface.
     $settings = $this->getUserInput($form_state, 'settings');
     if (empty($settings) && ($editor = Editor::load($filter_format->id()))) {
         $editor_settings = $editor->getSettings();
         $plugin_settings = NestedArray::getValue($editor_settings, ['plugins', 'video_embed', 'defaults', 'children']);
         $settings = $plugin_settings ? $plugin_settings : [];
     }
     // Create a settings form from the existing video formatter.
     $form['settings'] = Video::mockInstance($settings)->settingsForm([], new FormState());
     $form['settings']['#type'] = 'fieldset';
     $form['settings']['#title'] = $this->t('Settings');
     $form['actions'] = ['#type' => 'actions'];
     $form['actions']['save_modal'] = ['#type' => 'submit', '#value' => $this->t('Save'), '#submit' => [], '#ajax' => ['callback' => '::ajaxSubmit', 'event' => 'click', 'wrapper' => 'video-embed-dialog-form']];
     return $form;
 }
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:28,代码来源:VideoEmbedDialog.php


示例16: preRenderTextFormat

 /**
  * Additional #pre_render callback for 'text_format' elements.
  */
 function preRenderTextFormat(array $element)
 {
     // Allow modules to programmatically enforce no client-side editor by
     // setting the #editor property to FALSE.
     if (isset($element['#editor']) && !$element['#editor']) {
         return $element;
     }
     // filter_process_format() copies properties to the expanded 'value' child
     // element, including the #pre_render property. Skip this text format
     // widget, if it contains no 'format'.
     if (!isset($element['format'])) {
         return $element;
     }
     $format_ids = array_keys($element['format']['format']['#options']);
     // Early-return if no text editor is associated with any of the text formats.
     $editors = Editor::loadMultiple($format_ids);
     if (count($editors) === 0) {
         return $element;
     }
     // Use a hidden element for a single text format.
     $field_id = $element['value']['#id'];
     if (!$element['format']['format']['#access']) {
         // Use the first (and only) available text format.
         $format_id = $format_ids[0];
         $element['format']['editor'] = array('#type' => 'hidden', '#name' => $element['format']['format']['#name'], '#value' => $format_id, '#attributes' => array('class' => array('editor'), 'data-editor-for' => $field_id));
     } else {
         $element['format']['format']['#attributes']['class'][] = 'editor';
         $element['format']['format']['#attributes']['data-editor-for'] = $field_id;
     }
     // Hide the text format's filters' guidelines of those text formats that have
     // a text editor associated: they're rather useless when using a text editor.
     foreach ($editors as $format_id => $editor) {
         $element['format']['guidelines'][$format_id]['#access'] = FALSE;
     }
     // Attach Text Editor module's (this module) library.
     $element['#attached']['library'][] = 'editor/drupal.editor';
     // Attach attachments for all available editors.
     $element['#attached'] = drupal_merge_attached($element['#attached'], $this->pluginManager->getAttachments($format_ids));
     // Apply XSS filters when editing content if necessary. Some types of text
     // editors cannot guarantee that the end user won't become a victim of XSS.
     if (!empty($element['value']['#value'])) {
         $original = $element['value']['#value'];
         $format = FilterFormat::load($element['format']['format']['#value']);
         // Ensure XSS-safety for the current text format/editor.
         $filtered = editor_filter_xss($original, $format);
         if ($filtered !== FALSE) {
             $element['value']['#value'] = $filtered;
         }
         // Only when the user has access to multiple text formats, we must add data-
         // attributes for the original value and change tracking, because they are
         // only necessary when the end user can switch between text formats/editors.
         if ($element['format']['format']['#access']) {
             $element['value']['#attributes']['data-editor-value-is-changed'] = 'false';
             $element['value']['#attributes']['data-editor-value-original'] = $original;
         }
     }
     return $element;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:61,代码来源:Element.php


示例17: testCalculateDependencies

 /**
  * @covers ::calculateDependencies
  */
 public function testCalculateDependencies()
 {
     $format_id = 'filter.format.test';
     $values = array('editor' => $this->editorId, 'format' => $format_id);
     $plugin = $this->getMockBuilder('Drupal\\editor\\Plugin\\EditorPluginInterface')->disableOriginalConstructor()->getMock();
     $plugin->expects($this->once())->method('getPluginDefinition')->will($this->returnValue(array('provider' => 'test_module')));
     $plugin->expects($this->once())->method('getDefaultSettings')->will($this->returnValue(array()));
     $this->editorPluginManager->expects($this->any())->method('createInstance')->with($this->editorId)->will($this->returnValue($plugin));
     $entity = new Editor($values, $this->entityTypeId);
     $filter_format = $this->getMock('Drupal\\Core\\Config\\Entity\\ConfigEntityInterface');
     $filter_format->expects($this->once())->method('getConfigDependencyName')->will($this->returnValue('filter.format.test'));
     $storage = $this->getMock('Drupal\\Core\\Entity\\EntityStorageInterface');
     $storage->expects($this->once())->method('load')->with($format_id)->will($this->returnValue($filter_format));
     $this->entityManager->expects($this->once())->method('getStorage')->with('filter_format')->will($this->returnValue($storage));
     $dependencies = $entity->calculateDependencies()->getDependencies();
     $this->assertContains('test_module', $dependencies['module']);
     $this->assertContains('filter.format.test', $dependencies['config']);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:21,代码来源:EditorConfigEntityUnitTest.php


示例18: 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


示例19: getEnabledPluginFiles

 /**
  * Retrieves enabled plugins' files, keyed by plugin ID.
  *
  * For CKEditor plugins that implement:
  *  - CKEditorPluginButtonsInterface, not CKEditorPluginContextualInterface,
  *     a plugin is enabled if at least one of its buttons is in the toolbar;
  *  - CKEditorPluginContextualInterface, not CKEditorPluginButtonsInterface,
  *     a plugin is enabled if its isEnabled() method returns TRUE
  *  - both of these interfaces, a plugin is enabled if either is the case.
  *
  * Internal plugins (those that are part of the bundled build of CKEditor) are
  * excluded by default, since they are loaded implicitly. If you need to know
  * even implicitly loaded (i.e. internal) plugins, then set the optional
  * second parameter.
  *
  * @param \Drupal\editor\Entity\Editor $editor
  *   A configured text editor object.
  * @param bool $include_internal_plugins
  *   Defaults to FALSE. When set to TRUE, plugins whose isInternal() method
  *   returns TRUE will also be included.
  * @return array
  *   A list of the enabled CKEditor plugins, with the plugin IDs as keys and
  *   the Drupal root-relative plugin files as values.
  *   For internal plugins, the value is NULL.
  */
 public function getEnabledPluginFiles(Editor $editor, $include_internal_plugins = FALSE)
 {
     $plugins = array_keys($this->getDefinitions());
     // Flatten each row.
     $toolbar_rows = array();
     $settings = $editor->getSettings();
     foreach ($settings['toolbar']['rows'] as $row_number => $row) {
         $toolbar_rows[] = array_reduce($settings['toolbar']['rows'][$row_number], function (&$result, $button_group) {
             return array_merge($result, $button_group['items']);
         }, array());
     }
     $toolbar_buttons = array_unique(NestedArray::mergeDeepArray($toolbar_rows));
     $enabled_plugins = array();
     $additional_plugins = array();
     foreach ($plugins as $plugin_id) {
         $plugin = $this->createInstance($plugin_id);
         if (!$include_internal_plugins && $plugin->isInternal()) {
             continue;
         }
         $enabled = FALSE;
         // Enable this plugin if it provides a button that has been enabled.
         if ($plugin instanceof CKEditorPluginButtonsInterface) {
             $plugin_buttons = array_keys($plugin->getButtons());
             $enabled = count(array_intersect($toolbar_buttons, $plugin_buttons)) > 0;
         }
         // Otherwise enable this plugin if it declares itself as enabled.
         if (!$enabled && $plugin instanceof CKEditorPluginContextualInterface) {
             $enabled = $plugin->isEnabled($editor);
         }
         if ($enabled) {
             $enabled_plugins[$plugin_id] = $plugin->isInternal() ? NULL : $plugin->getFile();
             // Check if this plugin has dependencies that also need to be enabled.
             $additional_plugins = array_merge($additional_plugins, array_diff($plugin->getDependencies($editor), $additional_plugins));
         }
     }
     // Add the list of dependent plugins.
     foreach ($additional_plugins as $plugin_id) {
         $plugin = $this->createInstance($plugin_id);
         $enabled_plugins[$plugin_id] = $plugin->isInternal() ? NULL : $plugin->getFile();
     }
     // Always return plugins in the same order.
     asort($enabled_plugins);
     return $enabled_plugins;
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:69,代码来源:CKEditorPluginManager.php


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Entity\EntityTest类代码示例发布时间:2022-05-23
下一篇:
PHP TypedData\TypedDataManager类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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