class RestPermissions in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/rest/src/RestPermissions.php \Drupal\rest\RestPermissions
Provides rest module permissions.
Hierarchy
- class \Drupal\rest\RestPermissions implements ContainerInjectionInterface
Expanded class hierarchy of RestPermissions
File
- core/
modules/ rest/ src/ RestPermissions.php, line 18 - Contains \Drupal\rest\RestPermissions.
Namespace
Drupal\restView source
class RestPermissions implements ContainerInjectionInterface {
/**
* The rest resource plugin manager.
*
* @var \Drupal\rest\Plugin\Type\ResourcePluginManager
*/
protected $restPluginManager;
/**
* The config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* Constructs a new RestPermissions instance.
*
* @param \Drupal\rest\Plugin\Type\ResourcePluginManager $rest_plugin_manager
* The rest resource plugin manager.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
*/
public function __construct(ResourcePluginManager $rest_plugin_manager, ConfigFactoryInterface $config_factory) {
$this->restPluginManager = $rest_plugin_manager;
$this->configFactory = $config_factory;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('plugin.manager.rest'), $container
->get('config.factory'));
}
/**
* Returns an array of REST permissions.
*
* @return array
*/
public function permissions() {
$permissions = [];
$resources = $this->configFactory
->get('rest.settings')
->get('resources');
if ($resources && ($enabled = array_intersect_key($this->restPluginManager
->getDefinitions(), $resources))) {
foreach ($enabled as $key => $resource) {
$plugin = $this->restPluginManager
->getInstance([
'id' => $key,
]);
$permissions = array_merge($permissions, $plugin
->permissions());
}
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RestPermissions:: |
protected | property | The config factory. | |
RestPermissions:: |
protected | property | The rest resource plugin manager. | |
RestPermissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
RestPermissions:: |
public | function | Returns an array of REST permissions. | |
RestPermissions:: |
public | function | Constructs a new RestPermissions instance. |