Skip to content
Snippets Groups Projects
Commit 4ca088c2 authored by Jess's avatar Jess
Browse files

Revert "Issue #2723589 by Ashish.Dalvi, gaurav.pahuja, marvin_B8, valthebald:...

Revert "Issue #2723589 by Ashish.Dalvi, gaurav.pahuja, marvin_B8, valthebald: Remove entity_load* usage for filter_format entity type"

This reverts commit 39498e7d.
parent 20a08028
No related branches found
No related tags found
No related merge requests found
Showing
with 37 additions and 47 deletions
......@@ -592,8 +592,7 @@ function template_preprocess_form_element_label(&$variables) {
* // 1 (or no value explicitly set) means the operation is finished
* // and the batch processing can continue to the next operation.
*
* $nodes = \Drupal::entityTypeManager()->getStorage('node')
* ->loadByProperties(['uid' => $uid, 'type' => $type]);
* $nodes = entity_load_multiple_by_properties('node', array('uid' => $uid, 'type' => $type));
* $node = reset($nodes);
* $context['results'][] = $node->id() . ' : ' . SafeMarkup::checkPlain($node->label());
* $context['message'] = SafeMarkup::checkPlain($node->label());
......
......@@ -245,7 +245,7 @@ function testNewFormat() {
'editor[editor]' => 'ckeditor',
);
$this->drupalPostAjaxForm(NULL, $edit, 'editor_configure');
$filter_format = FilterFormat::load('amazing_format');
$filter_format = entity_load('filter_format', 'amazing_format');
$this->assertFalse($filter_format, 'No FilterFormat config entity exists yet.');
$editor = Editor::load('amazing_format');
$this->assertFalse($editor, 'No Editor config entity exists yet.');
......@@ -270,7 +270,7 @@ function testNewFormat() {
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
// Ensure a FilterFormat object exists now.
$filter_format = FilterFormat::load('amazing_format');
$filter_format = entity_load('filter_format', 'amazing_format');
$this->assertTrue($filter_format instanceof FilterFormatInterface, 'A FilterFormat config entity exists now.');
// Ensure an Editor object exists now, with the proper settings.
......
......@@ -10,7 +10,6 @@
use Drupal\Core\Language\LanguageInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\filter\Entity\FilterFormat;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\simpletest\WebTestBase;
......@@ -78,11 +77,11 @@ protected function setUp() {
];
/** @var \Drupal\filter\FilterFormatInterface $filter_test_format */
$filter_test_format = FilterFormat::load('filter_test');
$filter_test_format = entity_load('filter_format', 'filter_test');
/** @var \Drupal\filter\FilterFormatInterface $filtered_html_format */
$filtered_html_format = FilterFormat::load('filtered_html');
$filtered_html_format = entity_load('filter_format', 'filtered_html');
/** @var \Drupal\filter\FilterFormatInterface $full_html_format */
$full_html_format = FilterFormat::load('full_html');
$full_html_format = entity_load('filter_format', 'full_html');
$admin_permissions = array_merge(
$translator_permissions,
......
......@@ -4,7 +4,6 @@
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\filter\Entity\FilterFormat;
use Drupal\quickedit\Plugin\InPlaceEditorInterface;
use Drupal\filter\Plugin\FilterInterface;
......@@ -62,7 +61,7 @@ function getMetadata(FieldItemListInterface $items) {
* @return bool
*/
protected function textFormatHasTransformationFilters($format_id) {
$format = FilterFormat::load($format_id);
$format = entity_load('filter_format', $format_id);
return (bool) count(array_intersect(array(FilterInterface::TYPE_TRANSFORM_REVERSIBLE, FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE), $format->getFiltertypes()));
}
......
......@@ -202,7 +202,7 @@ function testFilterAdmin() {
$this->assertResponse(403, 'The fallback format cannot be disabled.');
// Verify access permissions to Full HTML format.
$full_format = FilterFormat::load($full);
$full_format = entity_load('filter_format', $full);
$this->assertTrue($full_format->access('use', $this->adminUser), 'Admin user may use Full HTML.');
$this->assertFalse($full_format->access('use', $this->webUser), 'Web user may not use Full HTML.');
......@@ -236,7 +236,7 @@ function testFilterAdmin() {
));
$this->assertTrue(!empty($elements), 'Reorder confirmed in admin interface.');
$filter_format = FilterFormat::load($restricted);
$filter_format = entity_load('filter_format', $restricted);
foreach ($filter_format->filters() as $filter_name => $filter) {
if ($filter_name == $second_filter || $filter_name == $first_filter) {
$filters[] = $filter_name;
......@@ -257,7 +257,7 @@ function testFilterAdmin() {
$this->assertRaw(t('Added text format %format.', array('%format' => $edit['name'])), 'New filter created.');
filter_formats_reset();
$format = FilterFormat::load($edit['format']);
$format = entity_load('filter_format', $edit['format']);
$this->assertNotNull($format, 'Format found in database.');
$this->drupalGet('admin/config/content/formats/manage/' . $format->id());
$this->assertFieldByName('roles[' . RoleInterface::AUTHENTICATED_ID . ']', '', 'Role found.');
......@@ -270,7 +270,7 @@ function testFilterAdmin() {
$this->assertRaw(t('Disabled text format %format.', array('%format' => $edit['name'])), 'Format successfully disabled.');
// Allow authenticated users on full HTML.
$format = FilterFormat::load($full);
$format = entity_load('filter_format', $full);
$edit = array();
$edit['roles[' . RoleInterface::ANONYMOUS_ID . ']'] = 0;
$edit['roles[' . RoleInterface::AUTHENTICATED_ID . ']'] = 1;
......
......@@ -3,7 +3,6 @@
namespace Drupal\filter\Tests;
use Drupal\Component\Utility\Unicode;
use Drupal\filter\Entity\FilterFormat;
use Drupal\simpletest\WebTestBase;
/**
......@@ -36,7 +35,7 @@ function testDefaultTextFormats() {
);
$this->drupalPostForm('admin/config/content/formats/add', $edit, t('Save configuration'));
$this->resetFilterCaches();
$formats[] = FilterFormat::load($edit['format']);
$formats[] = entity_load('filter_format', $edit['format']);
}
list($first_format, $second_format) = $formats;
$second_format_permission = $second_format->getPermissionName();
......
......@@ -3,7 +3,6 @@
namespace Drupal\filter\Tests;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\filter\Entity\FilterFormat;
use Drupal\simpletest\WebTestBase;
/**
......@@ -41,11 +40,11 @@ protected function setUp() {
parent::setUp();
/** @var \Drupal\filter\FilterFormatInterface $filter_test_format */
$filter_test_format = FilterFormat::load('filter_test');
$filter_test_format = entity_load('filter_format', 'filter_test');
/** @var \Drupal\filter\FilterFormatInterface $filtered_html_format */
$filtered_html_format = FilterFormat::load('filtered_html');
$filtered_html_format = entity_load('filter_format', 'filtered_html');
/** @var \Drupal\filter\FilterFormatInterface $full_html_format */
$full_html_format = FilterFormat::load('full_html');
$full_html_format = entity_load('filter_format', 'full_html');
// Create users.
$this->adminUser = $this->drupalCreateUser(array(
......
......@@ -4,7 +4,6 @@
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Access\AccessResult;
use Drupal\filter\Entity\FilterFormat;
use Drupal\simpletest\WebTestBase;
/**
......@@ -90,7 +89,7 @@ protected function setUp() {
);
$this->drupalPostForm('admin/config/content/formats/add', $edit, t('Save configuration'));
$this->resetFilterCaches();
$formats[] = FilterFormat::load($edit['format']);
$formats[] = entity_load('filter_format', $edit['format']);
}
list($this->allowedFormat, $this->secondAllowedFormat, $this->disallowedFormat) = $formats;
$this->drupalLogout();
......@@ -121,7 +120,7 @@ protected function setUp() {
function testFormatPermissions() {
// Make sure that a regular user only has access to the text formats for
// which they were granted access.
$fallback_format = FilterFormat::load(filter_fallback_format());
$fallback_format = entity_load('filter_format', filter_fallback_format());
$this->assertTrue($this->allowedFormat->access('use', $this->webUser), 'A regular user has access to use a text format they were granted access to.');
$this->assertEqual(AccessResult::allowed()->addCacheContexts(['user.permissions']), $this->allowedFormat->access('use', $this->webUser, TRUE), 'A regular user has access to use a text format they were granted access to.');
$this->assertFalse($this->disallowedFormat->access('use', $this->webUser), 'A regular user does not have access to use a text format they were not granted access to.');
......@@ -198,7 +197,7 @@ function testFormatRoles() {
$this->assertFalse(in_array($this->disallowedFormat->id(), array_keys(filter_get_formats_by_role($rid))), 'A text format which a role does not have access to does not appear in the list of formats available to that role.');
// Check that the fallback format is always allowed.
$this->assertEqual(filter_get_roles_by_format(FilterFormat::load(filter_fallback_format())), user_role_names(), 'All roles have access to the fallback format.');
$this->assertEqual(filter_get_roles_by_format(entity_load('filter_format', filter_fallback_format())), user_role_names(), 'All roles have access to the fallback format.');
$this->assertTrue(in_array(filter_fallback_format(), array_keys(filter_get_formats_by_role($rid))), 'The fallback format appears in the list of allowed formats for any role.');
}
......
......@@ -2,7 +2,6 @@
namespace Drupal\filter\Tests;
use Drupal\filter\Entity\FilterFormat;
use Drupal\simpletest\WebTestBase;
use Drupal\filter\Plugin\FilterInterface;
use Drupal\user\RoleInterface;
......@@ -37,7 +36,7 @@ protected function setUp() {
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
/** @var \Drupal\filter\Entity\FilterFormat $filtered_html_format */
$filtered_html_format = FilterFormat::load('filtered_html');
$filtered_html_format = entity_load('filter_format', 'filtered_html');
$filtered_html_permission = $filtered_html_format->getPermissionName();
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array($filtered_html_permission));
......
......@@ -100,7 +100,7 @@ function testCheckMarkupFilterSubset() {
*/
function testFilterFormatAPI() {
// Test on filtered_html.
$filtered_html_format = FilterFormat::load('filtered_html');
$filtered_html_format = entity_load('filter_format', 'filtered_html');
$this->assertIdentical(
$filtered_html_format->getHtmlRestrictions(),
array(
......@@ -121,7 +121,7 @@ function testFilterFormatAPI() {
);
// Test on full_html.
$full_html_format = FilterFormat::load('full_html');
$full_html_format = entity_load('filter_format', 'full_html');
$this->assertIdentical(
$full_html_format->getHtmlRestrictions(),
FALSE, // Every tag is allowed.
......@@ -334,7 +334,7 @@ function testTypedDataAPI() {
$this->assertTrue($data instanceof OptionsProviderInterface, 'Typed data object implements \Drupal\Core\TypedData\OptionsProviderInterface');
$filtered_html_user = $this->createUser(array('uid' => 2), array(
FilterFormat::load('filtered_html')->getPermissionName(),
entity_load('filter_format', 'filtered_html')->getPermissionName(),
));
// Test with anonymous user.
......
......@@ -93,7 +93,7 @@ function verifyTextFormat($format) {
$default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId();
// Verify the loaded filter has all properties.
$filter_format = FilterFormat::load($format->id());
$filter_format = entity_load('filter_format', $format->id());
$this->assertEqual($filter_format->id(), $format->id(), format_string('filter_format_load: Proper format id for text format %format.', $t_args));
$this->assertEqual($filter_format->label(), $format->label(), format_string('filter_format_load: Proper title for text format %format.', $t_args));
$this->assertEqual($filter_format->get('weight'), $format->get('weight'), format_string('filter_format_load: Proper weight for text format %format.', $t_args));
......
......@@ -2,7 +2,6 @@
namespace Drupal\Tests\filter\Kernel;
use Drupal\filter\Entity\FilterFormat;
use Drupal\KernelTests\KernelTestBase;
use Drupal\user\RoleInterface;
......@@ -32,7 +31,7 @@ protected function setUp() {
*/
function testInstallation() {
// Verify that the format was installed correctly.
$format = FilterFormat::load('filter_test');
$format = entity_load('filter_format', 'filter_test');
$this->assertTrue((bool) $format);
$this->assertEqual($format->id(), 'filter_test');
$this->assertEqual($format->label(), 'Test format');
......@@ -72,7 +71,7 @@ function testInstallation() {
*/
function testUpdateRoles() {
// Verify role permissions declared in default config.
$format = FilterFormat::load('filter_test');
$format = entity_load('filter_format', 'filter_test');
$this->assertEqual(array_keys(filter_get_roles_by_format($format)), array(
RoleInterface::ANONYMOUS_ID,
RoleInterface::AUTHENTICATED_ID,
......@@ -85,7 +84,7 @@ function testUpdateRoles() {
$format->save();
// Verify that roles have not been updated.
$format = FilterFormat::load('filter_test');
$format = entity_load('filter_format', 'filter_test');
$this->assertEqual(array_keys(filter_get_roles_by_format($format)), array(
RoleInterface::ANONYMOUS_ID,
RoleInterface::AUTHENTICATED_ID,
......
......@@ -52,11 +52,11 @@ protected function setUp() {
* Test the changed time after API and FORM save without changes.
*/
public function testChangedTimeAfterSaveWithoutChanges() {
$storage = $this->container->get('entity_type.manager')->getStorage('node');
$storage->resetCache([1]);
$node = $storage->load(1);
$node = entity_load('node', 1);
$changed_timestamp = $node->getChangedTime();
$node->save();
$node = entity_load('node', 1, TRUE);
$this->assertEqual($changed_timestamp, $node->getChangedTime(), "The entity's changed time wasn't updated after API save without changes.");
// Ensure different save timestamps.
......@@ -65,8 +65,7 @@ public function testChangedTimeAfterSaveWithoutChanges() {
// Save the node on the regular node edit form.
$this->drupalPostForm('node/1/edit', array(), t('Save'));
$storage->resetCache([1]);
$node = $storage->load(1);
$node = entity_load('node', 1, TRUE);
$this->assertNotEqual($changed_timestamp, $node->getChangedTime(), "The entity's changed time was updated after form save without changes.");
}
......
......@@ -2,6 +2,8 @@
namespace Drupal\node\Tests;
use Drupal\node\Entity\Node;
/**
* Tests the loading of multiple nodes.
*
......@@ -37,9 +39,9 @@ function testNodeMultipleLoad() {
$this->assertText($node2->label(), 'Node title appears on the default listing.');
$this->assertNoText($node3->label(), 'Node title does not appear in the default listing.');
$this->assertNoText($node4->label(), 'Node title does not appear in the default listing.');
// Load nodes with only a condition. Nodes 3 and 4 will be loaded.
$nodes = $this->container->get('entity_type.manager')->getStorage('node')
->loadByProperties(array('promote' => 0));
$nodes = entity_load_multiple_by_properties('node', array('promote' => 0));
$this->assertEqual($node3->label(), $nodes[$node3->id()]->label(), 'Node was loaded.');
$this->assertEqual($node4->label(), $nodes[$node4->id()]->label(), 'Node was loaded.');
$count = count($nodes);
......
......@@ -3,7 +3,6 @@
namespace Drupal\system\Tests\Entity;
use Drupal\Core\Entity\EntityWithPluginCollectionInterface;
use Drupal\filter\Entity\FilterFormat;
use Drupal\image\Entity\ImageStyle;
use Drupal\search\Entity\SearchPage;
use Drupal\simpletest\WebTestBase;
......@@ -90,7 +89,7 @@ protected function doFilterFormatUpdate() {
$name = 'filter.format.plain_text';
/** @var $entity \Drupal\filter\Entity\FilterFormat */
$entity = FilterFormat::load('plain_text');
$entity = entity_load('filter_format', 'plain_text');
$plugin_collection = $entity->getPluginCollections()['filters'];
$filters = $entity->get('filters');
......
......@@ -7,7 +7,6 @@
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\String\StringFieldTest;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests the creation of text fields.
......@@ -212,7 +211,7 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) {
);
$this->drupalPostForm('admin/config/content/formats/add', $edit, t('Save configuration'));
filter_formats_reset();
$format = FilterFormat::load($edit['format']);
$format = entity_load('filter_format', $edit['format']);
$format_id = $format->id();
$permission = $format->getPermissionName();
$roles = $this->webUser->getRoles();
......
......@@ -8,7 +8,6 @@
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\filter\Entity\FilterFormat;
/**
* Implements hook_help().
......@@ -81,7 +80,7 @@ function text_summary($text, $format = NULL, $size = NULL) {
// Retrieve the filters of the specified text format, if any.
if (isset($format)) {
$filters = FilterFormat::load($format)->filters();
$filters = entity_load('filter_format', $format)->filters();
// If the specified format does not exist, return nothing. $text is already
// filtered text, but the remainder of this function will not be able to
// ensure a sane and secure summary.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment