Issue #2322233 by Temoor, Mirroar, estoyausente: Replace all instances of user_role_load(), entity_load('user_role') and entity_load_multiple('user_role') with static method calls.
parent
4fc159c65b
commit
331f2878fb
|
|
@ -9,6 +9,7 @@ namespace Drupal\aggregator\Tests;
|
||||||
|
|
||||||
use Drupal\aggregator\Entity\Feed;
|
use Drupal\aggregator\Entity\Feed;
|
||||||
use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase;
|
use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase;
|
||||||
|
use Drupal\user\Entity\Role;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the Feed entity's cache tags.
|
* Tests the Feed entity's cache tags.
|
||||||
|
|
@ -35,7 +36,7 @@ class FeedCacheTagsTest extends EntityWithUriCacheTagsTestBase {
|
||||||
|
|
||||||
// Give anonymous users permission to access feeds, so that we can verify
|
// Give anonymous users permission to access feeds, so that we can verify
|
||||||
// the cache tags of cached versions of feeds.
|
// the cache tags of cached versions of feeds.
|
||||||
$user_role = entity_load('user_role', DRUPAL_ANONYMOUS_RID);
|
$user_role = Role::load(DRUPAL_ANONYMOUS_RID);
|
||||||
$user_role->grantPermission('access news feeds');
|
$user_role->grantPermission('access news feeds');
|
||||||
$user_role->save();
|
$user_role->save();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ namespace Drupal\aggregator\Tests;
|
||||||
use Drupal\aggregator\Entity\Feed;
|
use Drupal\aggregator\Entity\Feed;
|
||||||
use Drupal\aggregator\Entity\Item;
|
use Drupal\aggregator\Entity\Item;
|
||||||
use Drupal\system\Tests\Entity\EntityCacheTagsTestBase;
|
use Drupal\system\Tests\Entity\EntityCacheTagsTestBase;
|
||||||
|
use Drupal\user\Entity\Role;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the Item entity's cache tags.
|
* Tests the Item entity's cache tags.
|
||||||
|
|
@ -36,7 +37,7 @@ class ItemCacheTagsTest extends EntityCacheTagsTestBase {
|
||||||
|
|
||||||
// Give anonymous users permission to access feeds, so that we can verify
|
// Give anonymous users permission to access feeds, so that we can verify
|
||||||
// the cache tags of cached versions of feed items.
|
// the cache tags of cached versions of feed items.
|
||||||
$user_role = entity_load('user_role', DRUPAL_ANONYMOUS_RID);
|
$user_role = Role::load(DRUPAL_ANONYMOUS_RID);
|
||||||
$user_role->grantPermission('access news feeds');
|
$user_role->grantPermission('access news feeds');
|
||||||
$user_role->save();
|
$user_role->save();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ use Drupal\comment\CommentManagerInterface;
|
||||||
use Drupal\Core\Entity\EntityInterface;
|
use Drupal\Core\Entity\EntityInterface;
|
||||||
use Drupal\field\Entity\FieldConfig;
|
use Drupal\field\Entity\FieldConfig;
|
||||||
use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase;
|
use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase;
|
||||||
|
use Drupal\user\Entity\Role;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the Comment entity's cache tags.
|
* Tests the Comment entity's cache tags.
|
||||||
|
|
@ -32,7 +33,7 @@ class CommentCacheTagsTest extends EntityWithUriCacheTagsTestBase {
|
||||||
|
|
||||||
// Give anonymous users permission to view comments, so that we can verify
|
// Give anonymous users permission to view comments, so that we can verify
|
||||||
// the cache tags of cached versions of comment pages.
|
// the cache tags of cached versions of comment pages.
|
||||||
$user_role = entity_load('user_role', DRUPAL_ANONYMOUS_RID);
|
$user_role = Role::load(DRUPAL_ANONYMOUS_RID);
|
||||||
$user_role->grantPermission('access comments');
|
$user_role->grantPermission('access comments');
|
||||||
$user_role->save();
|
$user_role->save();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ namespace Drupal\migrate_drupal\Tests\d6;
|
||||||
|
|
||||||
use Drupal\migrate\MigrateExecutable;
|
use Drupal\migrate\MigrateExecutable;
|
||||||
use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase;
|
use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase;
|
||||||
|
use Drupal\user\Entity\Role;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upgrade user roles to user.role.*.yml.
|
* Upgrade user roles to user.role.*.yml.
|
||||||
|
|
@ -56,22 +57,22 @@ class MigrateUserRoleTest extends MigrateDrupalTestBase {
|
||||||
/** @var \Drupal\migrate\entity\Migration $migration */
|
/** @var \Drupal\migrate\entity\Migration $migration */
|
||||||
$migration = entity_load('migration', 'd6_user_role');
|
$migration = entity_load('migration', 'd6_user_role');
|
||||||
$rid = 'anonymous';
|
$rid = 'anonymous';
|
||||||
$anonymous = entity_load('user_role', $rid);
|
$anonymous = Role::load($rid);
|
||||||
$this->assertEqual($anonymous->id(), $rid);
|
$this->assertEqual($anonymous->id(), $rid);
|
||||||
$this->assertEqual($anonymous->getPermissions(), array('migrate test anonymous permission', 'use text format filtered_html'));
|
$this->assertEqual($anonymous->getPermissions(), array('migrate test anonymous permission', 'use text format filtered_html'));
|
||||||
$this->assertEqual(array($rid), $migration->getIdMap()->lookupDestinationId(array(1)));
|
$this->assertEqual(array($rid), $migration->getIdMap()->lookupDestinationId(array(1)));
|
||||||
$rid = 'authenticated';
|
$rid = 'authenticated';
|
||||||
$authenticated = entity_load('user_role', $rid);
|
$authenticated = Role::load($rid);
|
||||||
$this->assertEqual($authenticated->id(), $rid);
|
$this->assertEqual($authenticated->id(), $rid);
|
||||||
$this->assertEqual($authenticated->getPermissions(), array('migrate test authenticated permission', 'use text format filtered_html'));
|
$this->assertEqual($authenticated->getPermissions(), array('migrate test authenticated permission', 'use text format filtered_html'));
|
||||||
$this->assertEqual(array($rid), $migration->getIdMap()->lookupDestinationId(array(2)));
|
$this->assertEqual(array($rid), $migration->getIdMap()->lookupDestinationId(array(2)));
|
||||||
$rid = 'migrate_test_role_1';
|
$rid = 'migrate_test_role_1';
|
||||||
$migrate_test_role_1 = entity_load('user_role', $rid);
|
$migrate_test_role_1 = Role::load($rid);
|
||||||
$this->assertEqual($migrate_test_role_1->id(), $rid);
|
$this->assertEqual($migrate_test_role_1->id(), $rid);
|
||||||
$this->assertEqual($migrate_test_role_1->getPermissions(), array(0 => 'migrate test role 1 test permission', 'use text format full_html'));
|
$this->assertEqual($migrate_test_role_1->getPermissions(), array(0 => 'migrate test role 1 test permission', 'use text format full_html'));
|
||||||
$this->assertEqual(array($rid), $migration->getIdMap()->lookupDestinationId(array(3)));
|
$this->assertEqual(array($rid), $migration->getIdMap()->lookupDestinationId(array(3)));
|
||||||
$rid = 'migrate_test_role_2';
|
$rid = 'migrate_test_role_2';
|
||||||
$migrate_test_role_2 = entity_load('user_role', $rid);
|
$migrate_test_role_2 = Role::load($rid);
|
||||||
$this->assertEqual($migrate_test_role_2->getPermissions(), array(
|
$this->assertEqual($migrate_test_role_2->getPermissions(), array(
|
||||||
'migrate test role 2 test permission',
|
'migrate test role 2 test permission',
|
||||||
'use PHP for settings',
|
'use PHP for settings',
|
||||||
|
|
@ -92,7 +93,7 @@ class MigrateUserRoleTest extends MigrateDrupalTestBase {
|
||||||
$this->assertEqual($migrate_test_role_2->id(), $rid);
|
$this->assertEqual($migrate_test_role_2->id(), $rid);
|
||||||
$this->assertEqual(array($rid), $migration->getIdMap()->lookupDestinationId(array(4)));
|
$this->assertEqual(array($rid), $migration->getIdMap()->lookupDestinationId(array(4)));
|
||||||
$rid = 'migrate_test_role_3_that_is_long';
|
$rid = 'migrate_test_role_3_that_is_long';
|
||||||
$migrate_test_role_3 = entity_load('user_role', $rid);
|
$migrate_test_role_3 = Role::load($rid);
|
||||||
$this->assertEqual($migrate_test_role_3->id(), $rid);
|
$this->assertEqual($migrate_test_role_3->id(), $rid);
|
||||||
$this->assertEqual(array($rid), $migration->getIdMap()->lookupDestinationId(array(5)));
|
$this->assertEqual(array($rid), $migration->getIdMap()->lookupDestinationId(array(5)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Drupal\views\ViewExecutable;
|
use Drupal\views\ViewExecutable;
|
||||||
|
use Drupal\user\Entity\Role;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements hook_views_query_substitutions().
|
* Implements hook_views_query_substitutions().
|
||||||
|
|
@ -31,9 +32,9 @@ function node_views_analyze(ViewExecutable $view) {
|
||||||
// check for no access control
|
// check for no access control
|
||||||
$access = $display->getOption('access');
|
$access = $display->getOption('access');
|
||||||
if (empty($access['type']) || $access['type'] == 'none') {
|
if (empty($access['type']) || $access['type'] == 'none') {
|
||||||
$anonymous_role = entity_load('user_role', DRUPAL_ANONYMOUS_RID);
|
$anonymous_role = Role::load(DRUPAL_ANONYMOUS_RID);
|
||||||
$anonymous_has_access = $anonymous_role && $anonymous_role->hasPermission('access content');
|
$anonymous_has_access = $anonymous_role && $anonymous_role->hasPermission('access content');
|
||||||
$authenticated_role = entity_load('user_role', DRUPAL_AUTHENTICATED_RID);
|
$authenticated_role = Role::load(DRUPAL_AUTHENTICATED_RID);
|
||||||
$authenticated_has_access = $authenticated_role && $authenticated_role->hasPermission('access content');
|
$authenticated_has_access = $authenticated_role && $authenticated_role->hasPermission('access content');
|
||||||
if (!$anonymous_has_access || !$authenticated_has_access) {
|
if (!$anonymous_has_access || !$authenticated_has_access) {
|
||||||
$ret[] = Analyzer::formatMessage(t('Some roles lack permission to access content, but display %display has no access control.', array('%display' => $display->display['display_title'])), 'warning');
|
$ret[] = Analyzer::formatMessage(t('Some roles lack permission to access content, but display %display has no access control.', array('%display' => $display->display['display_title'])), 'warning');
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ namespace Drupal\node\Tests;
|
||||||
|
|
||||||
use Drupal\Core\Entity\EntityInterface;
|
use Drupal\Core\Entity\EntityInterface;
|
||||||
use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase;
|
use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase;
|
||||||
|
use Drupal\user\Entity\Role;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the Node entity's cache tags.
|
* Tests the Node entity's cache tags.
|
||||||
|
|
@ -30,7 +31,7 @@ class NodeCacheTagsTest extends EntityWithUriCacheTagsTestBase {
|
||||||
|
|
||||||
// Give anonymous users permission to view nodes, so that we can verify the
|
// Give anonymous users permission to view nodes, so that we can verify the
|
||||||
// cache tags of cached versions of node pages.
|
// cache tags of cached versions of node pages.
|
||||||
$user_role = entity_load('user_role', DRUPAL_ANONYMOUS_RID);
|
$user_role = Role::load(DRUPAL_ANONYMOUS_RID);
|
||||||
$user_role->grantPermission('acess content');
|
$user_role->grantPermission('acess content');
|
||||||
$user_role->save();
|
$user_role->save();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ namespace Drupal\shortcut\Tests;
|
||||||
|
|
||||||
use Drupal\shortcut\Entity\Shortcut;
|
use Drupal\shortcut\Entity\Shortcut;
|
||||||
use Drupal\system\Tests\Entity\EntityCacheTagsTestBase;
|
use Drupal\system\Tests\Entity\EntityCacheTagsTestBase;
|
||||||
|
use Drupal\user\Entity\Role;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the Shortcut entity's cache tags.
|
* Tests the Shortcut entity's cache tags.
|
||||||
|
|
@ -30,7 +31,7 @@ class ShortcutCacheTagsTest extends EntityCacheTagsTestBase {
|
||||||
|
|
||||||
// Give anonymous users permission to customize shortcut links, so that we
|
// Give anonymous users permission to customize shortcut links, so that we
|
||||||
// can verify the cache tags of cached versions of shortcuts.
|
// can verify the cache tags of cached versions of shortcuts.
|
||||||
$user_role = entity_load('user_role', DRUPAL_ANONYMOUS_RID);
|
$user_role = Role::load(DRUPAL_ANONYMOUS_RID);
|
||||||
$user_role->grantPermission('customize shortcut links');
|
$user_role->grantPermission('customize shortcut links');
|
||||||
$user_role->grantPermission('access shortcuts');
|
$user_role->grantPermission('access shortcuts');
|
||||||
$user_role->save();
|
$user_role->save();
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ use Drupal\Core\StreamWrapper\PublicStream;
|
||||||
use Drupal\Core\Datetime\DrupalDateTime;
|
use Drupal\Core\Datetime\DrupalDateTime;
|
||||||
use Drupal\block\Entity\Block;
|
use Drupal\block\Entity\Block;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Drupal\user\Entity\Role;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test case for typical Drupal tests.
|
* Test case for typical Drupal tests.
|
||||||
|
|
@ -599,7 +600,7 @@ abstract class WebTestBase extends TestBase {
|
||||||
// Grant the specified permissions to the role, if any.
|
// Grant the specified permissions to the role, if any.
|
||||||
if (!empty($permissions)) {
|
if (!empty($permissions)) {
|
||||||
user_role_grant_permissions($role->id(), $permissions);
|
user_role_grant_permissions($role->id(), $permissions);
|
||||||
$assigned_permissions = entity_load('user_role', $role->id())->getPermissions();
|
$assigned_permissions = Role::load($role->id())->getPermissions();
|
||||||
$missing_permissions = array_diff($permissions, $assigned_permissions);
|
$missing_permissions = array_diff($permissions, $assigned_permissions);
|
||||||
if (!$missing_permissions) {
|
if (!$missing_permissions) {
|
||||||
$this->pass(String::format('Created permissions: @perms', array('@perms' => implode(', ', $permissions))), 'Role');
|
$this->pass(String::format('Created permissions: @perms', array('@perms' => implode(', ', $permissions))), 'Role');
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ use Drupal\Core\Cache\Cache;
|
||||||
use Drupal\Core\Entity\EntityInterface;
|
use Drupal\Core\Entity\EntityInterface;
|
||||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||||
use Drupal\system\Tests\Cache\PageCacheTagsTestBase;
|
use Drupal\system\Tests\Cache\PageCacheTagsTestBase;
|
||||||
|
use Drupal\user\Entity\Role;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides helper methods for Entity cache tags tests.
|
* Provides helper methods for Entity cache tags tests.
|
||||||
|
|
@ -53,7 +54,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
|
||||||
|
|
||||||
// Give anonymous users permission to view test entities, so that we can
|
// Give anonymous users permission to view test entities, so that we can
|
||||||
// verify the cache tags of cached versions of test entity pages.
|
// verify the cache tags of cached versions of test entity pages.
|
||||||
$user_role = entity_load('user_role', DRUPAL_ANONYMOUS_RID);
|
$user_role = Role::load(DRUPAL_ANONYMOUS_RID);
|
||||||
$user_role->grantPermission('view test entity');
|
$user_role->grantPermission('view test entity');
|
||||||
$user_role->save();
|
$user_role->save();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class RoleForm extends EntityForm {
|
||||||
'#size' => 30,
|
'#size' => 30,
|
||||||
'#maxlength' => 64,
|
'#maxlength' => 64,
|
||||||
'#machine_name' => array(
|
'#machine_name' => array(
|
||||||
'exists' => 'user_role_load',
|
'exists' => ['\Drupal\user\Entity\Role', 'load'],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$form['weight'] = array(
|
$form['weight'] = array(
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
namespace Drupal\user\Tests;
|
namespace Drupal\user\Tests;
|
||||||
|
|
||||||
use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase;
|
use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase;
|
||||||
|
use Drupal\user\Entity\Role;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the User entity's cache tags.
|
* Tests the User entity's cache tags.
|
||||||
|
|
@ -29,7 +30,7 @@ class UserCacheTagsTest extends EntityWithUriCacheTagsTestBase {
|
||||||
|
|
||||||
// Give anonymous users permission to view user profiles, so that we can
|
// Give anonymous users permission to view user profiles, so that we can
|
||||||
// verify the cache tags of cached versions of user profile pages.
|
// verify the cache tags of cached versions of user profile pages.
|
||||||
$user_role = entity_load('user_role', DRUPAL_ANONYMOUS_RID);
|
$user_role = Role::load(DRUPAL_ANONYMOUS_RID);
|
||||||
$user_role->grantPermission('access user profiles');
|
$user_role->grantPermission('access user profiles');
|
||||||
$user_role->save();
|
$user_role->save();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
namespace Drupal\user\Tests;
|
namespace Drupal\user\Tests;
|
||||||
|
|
||||||
use Drupal\simpletest\WebTestBase;
|
use Drupal\simpletest\WebTestBase;
|
||||||
|
use Drupal\user\Entity\Role;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests adding, editing and deleting user roles and changing role weights.
|
* Tests adding, editing and deleting user roles and changing role weights.
|
||||||
|
|
@ -42,7 +43,7 @@ class UserRoleAdminTest extends WebTestBase {
|
||||||
$edit = array('label' => $role_name, 'id' => $role_name);
|
$edit = array('label' => $role_name, 'id' => $role_name);
|
||||||
$this->drupalPostForm('admin/people/roles/add', $edit, t('Save'));
|
$this->drupalPostForm('admin/people/roles/add', $edit, t('Save'));
|
||||||
$this->assertRaw(t('Role %label has been added.', array('%label' => 123)));
|
$this->assertRaw(t('Role %label has been added.', array('%label' => 123)));
|
||||||
$role = entity_load('user_role', $role_name);
|
$role = Role::load($role_name);
|
||||||
$this->assertTrue(is_object($role), 'The role was successfully retrieved from the database.');
|
$this->assertTrue(is_object($role), 'The role was successfully retrieved from the database.');
|
||||||
|
|
||||||
// Check that the role was created in site default language.
|
// Check that the role was created in site default language.
|
||||||
|
|
@ -57,7 +58,8 @@ class UserRoleAdminTest extends WebTestBase {
|
||||||
$edit = array('label' => $role_name);
|
$edit = array('label' => $role_name);
|
||||||
$this->drupalPostForm("admin/people/roles/manage/{$role->id()}", $edit, t('Save'));
|
$this->drupalPostForm("admin/people/roles/manage/{$role->id()}", $edit, t('Save'));
|
||||||
$this->assertRaw(t('Role %label has been updated.', array('%label' => $role_name)));
|
$this->assertRaw(t('Role %label has been updated.', array('%label' => $role_name)));
|
||||||
$new_role = entity_load('user_role', $role->id(), TRUE);
|
\Drupal::entityManager()->getStorage('user_role')->resetCache(array($role->id()));
|
||||||
|
$new_role = Role::load($role->id());
|
||||||
$this->assertEqual($new_role->label(), $role_name, 'The role name has been successfully changed.');
|
$this->assertEqual($new_role->label(), $role_name, 'The role name has been successfully changed.');
|
||||||
|
|
||||||
// Test deleting a role.
|
// Test deleting a role.
|
||||||
|
|
@ -66,7 +68,8 @@ class UserRoleAdminTest extends WebTestBase {
|
||||||
$this->drupalPostForm(NULL, array(), t('Delete'));
|
$this->drupalPostForm(NULL, array(), t('Delete'));
|
||||||
$this->assertRaw(t('Role %label has been deleted.', array('%label' => $role_name)));
|
$this->assertRaw(t('Role %label has been deleted.', array('%label' => $role_name)));
|
||||||
$this->assertNoLinkByHref("admin/people/roles/manage/{$role->id()}", 'Role edit link removed.');
|
$this->assertNoLinkByHref("admin/people/roles/manage/{$role->id()}", 'Role edit link removed.');
|
||||||
$this->assertFalse(entity_load('user_role', $role->id(), TRUE), 'A deleted role can no longer be loaded.');
|
\Drupal::entityManager()->getStorage('user_role')->resetCache(array($role->id()));
|
||||||
|
$this->assertFalse(Role::load($role->id()), 'A deleted role can no longer be loaded.');
|
||||||
|
|
||||||
// Make sure that the system-defined roles can be edited via the user
|
// Make sure that the system-defined roles can be edited via the user
|
||||||
// interface.
|
// interface.
|
||||||
|
|
|
||||||
|
|
@ -387,7 +387,7 @@ function user_role_permissions(array $roles) {
|
||||||
if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update') {
|
if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update') {
|
||||||
return _user_role_permissions_update($roles);
|
return _user_role_permissions_update($roles);
|
||||||
}
|
}
|
||||||
$entities = entity_load_multiple('user_role', $roles);
|
$entities = Role::loadMultiple($roles);
|
||||||
$role_permissions = array();
|
$role_permissions = array();
|
||||||
foreach ($roles as $rid) {
|
foreach ($roles as $rid) {
|
||||||
$role_permissions[$rid] = isset($entities[$rid]) ? $entities[$rid]->getPermissions() : array();
|
$role_permissions[$rid] = isset($entities[$rid]) ? $entities[$rid]->getPermissions() : array();
|
||||||
|
|
@ -1155,7 +1155,7 @@ function user_roles($membersonly = FALSE, $permission = NULL) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$roles = entity_load_multiple('user_role');
|
$roles = Role::loadMultiple();
|
||||||
if ($membersonly) {
|
if ($membersonly) {
|
||||||
unset($roles[DRUPAL_ANONYMOUS_RID]);
|
unset($roles[DRUPAL_ANONYMOUS_RID]);
|
||||||
}
|
}
|
||||||
|
|
@ -1245,7 +1245,7 @@ function user_role_change_permissions($rid, array $permissions = array()) {
|
||||||
*/
|
*/
|
||||||
function user_role_grant_permissions($rid, array $permissions = array()) {
|
function user_role_grant_permissions($rid, array $permissions = array()) {
|
||||||
// Grant new permissions for the role.
|
// Grant new permissions for the role.
|
||||||
$role = entity_load('user_role', $rid);
|
$role = Role::load($rid);
|
||||||
foreach ($permissions as $permission) {
|
foreach ($permissions as $permission) {
|
||||||
$role->grantPermission($permission);
|
$role->grantPermission($permission);
|
||||||
}
|
}
|
||||||
|
|
@ -1265,7 +1265,7 @@ function user_role_grant_permissions($rid, array $permissions = array()) {
|
||||||
*/
|
*/
|
||||||
function user_role_revoke_permissions($rid, array $permissions = array()) {
|
function user_role_revoke_permissions($rid, array $permissions = array()) {
|
||||||
// Revoke permissions for the role.
|
// Revoke permissions for the role.
|
||||||
$role = entity_load('user_role', $rid);
|
$role = Role::load($rid);
|
||||||
foreach ($permissions as $permission) {
|
foreach ($permissions as $permission) {
|
||||||
$role->revokePermission($permission);
|
$role->revokePermission($permission);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue