Issue #2641528 by heykarthikwithu, Mac_Weber, naveenvalecha: Replace deprecated usage of entity_create('editor') with a direct call to Editor::create()

8.1.x
Nathaniel Catchpole 2016-02-16 10:15:43 +09:00
parent c3ae8b4c56
commit c3d6658c3a
10 changed files with 36 additions and 29 deletions

View File

@ -204,7 +204,7 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
}, array());
// Build a fake Editor object, which we'll use to generate JavaScript
// settings for this fake Editor instance.
$fake_editor = entity_create('editor', array(
$fake_editor = Editor::create(array(
'format' => $editor->id(),
'editor' => 'ckeditor',
'settings' => array(

View File

@ -7,6 +7,7 @@
namespace Drupal\ckeditor\Tests;
use Drupal\editor\Entity\Editor;
use Drupal\simpletest\WebTestBase;
/**
@ -48,10 +49,10 @@ class CKEditorLoadingTest extends WebTestBase {
'filters' => array(),
));
$filtered_html_format->save();
$editor = entity_create('editor', array(
$editor = Editor::create([
'format' => 'filtered_html',
'editor' => 'ckeditor',
));
]);
$editor->save();
// Create a second format without an associated editor so a drop down select

View File

@ -7,6 +7,7 @@
namespace Drupal\ckeditor\Tests;
use Drupal\editor\Entity\Editor;
use Drupal\simpletest\KernelTestBase;
/**
@ -44,10 +45,10 @@ class CKEditorPluginManagerTest extends KernelTestBase {
'filters' => array(),
));
$filtered_html_format->save();
$editor = entity_create('editor', array(
$editor = Editor::create([
'format' => 'filtered_html',
'editor' => 'ckeditor',
));
]);
$editor->save();
}

View File

@ -60,10 +60,10 @@ class CKEditorTest extends KernelTestBase {
),
));
$filtered_html_format->save();
$editor = entity_create('editor', array(
$editor = Editor::create([
'format' => 'filtered_html',
'editor' => 'ckeditor',
));
]);
$editor->save();
// Create "CKEditor" text editor plugin instance.

View File

@ -178,10 +178,10 @@ function editor_form_filter_admin_format_editor_configure($form, FormStateInterf
}
elseif (empty($editor) || $editor_value !== $editor->getEditor()) {
$format = $form_state->getFormObject()->getEntity();
$editor = entity_create('editor', array(
$editor = Editor::create([
'format' => $format->isNew() ? NULL : $format->id(),
'editor' => $editor_value,
));
]);
$form_state->set('editor', $editor);
}
}

View File

@ -7,6 +7,7 @@
namespace Drupal\editor\Tests;
use Drupal\editor\Entity\Editor;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
@ -47,10 +48,10 @@ class EditorFileUsageTest extends EntityUnitTestBase {
->save();
// Set up text editor.
$editor = entity_create('editor', array(
$editor = Editor::create([
'format' => 'filtered_html',
'editor' => 'unicorn',
));
]);
$editor->save();
// Create a node type for testing.

View File

@ -8,6 +8,7 @@
namespace Drupal\editor\Tests;
use Drupal\Core\Entity\Entity;
use Drupal\editor\Entity\Editor;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\simpletest\WebTestBase;
@ -113,7 +114,7 @@ class EditorLoadingTest extends WebTestBase {
*/
public function testLoading() {
// Only associate a text editor with the "Full HTML" text format.
$editor = entity_create('editor', array(
$editor = Editor::create([
'format' => 'full_html',
'editor' => 'unicorn',
'image_upload' => array(
@ -123,7 +124,7 @@ class EditorLoadingTest extends WebTestBase {
'max_size' => '',
'max_dimensions' => array('width' => '', 'height' => ''),
)
));
]);
$editor->save();
// The normal user:
@ -166,10 +167,10 @@ class EditorLoadingTest extends WebTestBase {
$this->drupalLogout($this->privilegedUser);
// Also associate a text editor with the "Plain Text" text format.
$editor = entity_create('editor', array(
$editor = Editor::create([
'format' => 'plain_text',
'editor' => 'unicorn',
));
]);
$editor->save();
// The untrusted user:
@ -221,7 +222,7 @@ class EditorLoadingTest extends WebTestBase {
*/
public function testSupportedElementTypes() {
// Associate the unicorn text editor with the "Full HTML" text format.
$editor = entity_create('editor', array(
$editor = Editor::create([
'format' => 'full_html',
'editor' => 'unicorn',
'image_upload' => array(
@ -231,7 +232,7 @@ class EditorLoadingTest extends WebTestBase {
'max_size' => '',
'max_dimensions' => array('width' => '', 'height' => ''),
)
));
]);
$editor->save();
// Create an "page" node that uses the full_html text format.
@ -255,10 +256,10 @@ class EditorLoadingTest extends WebTestBase {
// Associate the trex text editor with the "Full HTML" text format.
$editor->delete();
entity_create('editor', array(
Editor::create([
'format' => 'full_html',
'editor' => 'trex',
))->save();
])->save();
$this->drupalGet('node/1/edit');
list( , $editor_settings_present, $editor_js_present, $field, $format_selector) = $this->getThingsToCheck('field-text', 'input');

View File

@ -7,6 +7,7 @@
namespace Drupal\editor\Tests;
use Drupal\editor\Entity\Editor;
use Drupal\simpletest\KernelTestBase;
/**
@ -79,10 +80,10 @@ class EditorManagerTest extends KernelTestBase {
// Case 3: a text editor available & associated (but associated only with
// the 'Full HTML' text format).
$unicorn_plugin = $this->editorManager->createInstance('unicorn');
$editor = entity_create('editor', array(
$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(

View File

@ -8,6 +8,7 @@
namespace Drupal\editor\Tests;
use Drupal\Component\Serialization\Json;
use Drupal\editor\Entity\Editor;
use Drupal\simpletest\WebTestBase;
/**
@ -116,10 +117,10 @@ class EditorSecurityTest extends WebTestBase {
),
));
$format->save();
$editor = entity_create('editor', array(
$editor = Editor::create([
'format' => 'restricted_with_editor',
'editor' => 'unicorn',
));
]);
$editor->save();
$format = entity_create('filter_format', array(
'format' => 'restricted_plus_dangerous_tag_with_editor',
@ -136,10 +137,10 @@ class EditorSecurityTest extends WebTestBase {
),
));
$format->save();
$editor = entity_create('editor', array(
$editor = Editor::create([
'format' => 'restricted_plus_dangerous_tag_with_editor',
'editor' => 'unicorn',
));
]);
$editor->save();
$format = entity_create('filter_format', array(
'format' => 'unrestricted_without_editor',
@ -155,10 +156,10 @@ class EditorSecurityTest extends WebTestBase {
'filters' => array(),
));
$format->save();
$editor = entity_create('editor', array(
$editor = Editor::create([
'format' => 'unrestricted_with_editor',
'editor' => 'unicorn',
));
]);
$editor->save();

View File

@ -10,6 +10,7 @@ namespace Drupal\editor\Tests;
use Drupal\Component\Serialization\Json;
use Drupal\Core\EventSubscriber\AjaxResponseSubscriber;
use Drupal\Core\Language\LanguageInterface;
use Drupal\editor\Entity\Editor;
use Drupal\quickedit\MetadataGenerator;
use Drupal\quickedit\Tests\QuickEditTestBase;
use Drupal\quickedit_test\MockEditEntityFieldAccessCheck;
@ -95,10 +96,10 @@ class QuickEditIntegrationTest extends QuickEditTestBase {
$full_html_format->save();
// Associate text editor with text format.
$editor = entity_create('editor', array(
$editor = Editor::create([
'format' => $full_html_format->id(),
'editor' => 'unicorn',
));
]);
$editor->save();
// Also create a text format without an associated text editor.