FarmRoleStorage.php in farmOS 2.x
File
modules/core/role/src/FarmRoleStorage.php
View source
<?php
namespace Drupal\farm_role;
use Drupal\Component\Uuid\UuidInterface;
use Drupal\Core\Cache\MemoryCache\MemoryCacheInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\user\RoleStorage;
use Symfony\Component\DependencyInjection\ContainerInterface;
class FarmRoleStorage extends RoleStorage {
protected $managedRolePermissionsManager;
public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, MemoryCacheInterface $memory_cache, ManagedRolePermissionsManagerInterface $managed_role_permissions_manager) {
parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager, $memory_cache);
$this->managedRolePermissionsManager = $managed_role_permissions_manager;
}
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static($entity_type, $container
->get('config.factory'), $container
->get('uuid'), $container
->get('language_manager'), $container
->get('entity.memory_cache'), $container
->get('plugin.manager.managed_role_permissions'));
}
public function isPermissionInRoles($permission, array $rids) {
$has_permission = parent::isPermissionInRoles($permission, $rids);
if (!$has_permission) {
foreach ($this
->loadMultiple($rids) as $role) {
$has_permission = $this->managedRolePermissionsManager
->isPermissionInRole($permission, $role);
if ($has_permission) {
break;
}
}
}
return $has_permission;
}
}