editor_load example


  public function getAttachments(array $format_ids) {
    $attachments = ['library' => []];

    $settings = [];
    foreach ($format_ids as $format_id) {
      $editor = editor_load($format_id);
      if (!$editor) {
        continue;
      }

      $plugin = $this->createInstance($editor->getEditor());
      $plugin_definition = $plugin->getPluginDefinition();

      // Libraries.       $attachments['library'] = array_merge($attachments['library']$plugin->getLibraries($editor));

      // Format-specific JavaScript settings.


  /** * Verifies unicorn editor configuration. * * @param string $format_id * The format machine name. * @param bool $ponies_too * The expected value of the ponies_too setting. */
  protected function verifyUnicornEditorConfiguration($format_id$ponies_too = TRUE) {
    $editor = editor_load($format_id);
    $settings = $editor->getSettings();
    $this->assertSame('unicorn', $editor->getEditor(), 'The text editor is configured correctly.');
    $this->assertSame($ponies_too$settings['ponies_too'], 'The text editor settings are stored correctly.');
    $this->drupalGet('admin/config/content/formats/manage/' . $format_id);
    $select = $this->assertSession()->selectExists('editor[editor]');
    $this->assertFalse($select->hasAttribute('disabled'));
    $options = $select->findAll('css', 'option');
    $this->assertCount(2, $options);
    $this->assertTrue($options[1]->isSelected(), 'Option 2 ("Unicorn Editor") is selected.');
  }

}
Home | Imprint | This part of the site doesn't use cookies.