Skip to content
Snippets Groups Projects
Commit f2bca91a authored by Eric Bremner's avatar Eric Bremner Committed by Kevin Paxman
Browse files

ISTWCMS-4954: add drush command to set permissions

parent 70c88eee
No related branches found
No related tags found
1 merge request!133Feature/istwcms 4954 ebremner features
services:
uw_cfg_common.commands:
class: Drupal\uw_cfg_common\Commands\UwDrushCommands
arguments: ['@entity_type.manager']
tags:
- { name: drush.command }
<?php
namespace Drupal\uw_cfg_common\Commands;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\uw_cfg_common\UwRoles\UwRoles;
use Drush\Commands\DrushCommands;
/**
* Drush commands for uw_cfg_common module.
*
* @package Drupal\uw_cfg_common\Commands
*/
class UwDrushCommands extends DrushCommands {
/**
* Entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* {@inheritDoc}
*/
public function __construct(EntityTypeManagerInterface $entityTypeManager) {
$this->entityTypeManager = $entityTypeManager;
}
/**
* Drush command to update permissions.
*
* @command uwcfgcommon:catalog
* @aliases uwperm
* @usage uwperm
*/
public function updatePermissions() {
// Get all the role ids in the system.
$rids = UwRoles::getAllRoles();
// Step through each rid and set the permissions.
foreach ($rids as $rid) {
// Get the info about the role.
$uw_role = UwRoles::getUwRole($rid);
// Set the permissions for the role.
UwRoles::setUwPermissions($uw_role);
// Set message for specific role setting permissions.
$this->logger()->success('Permissions set for ' . $uw_role['label'] . '.');
}
// Set message for command completed.
$this->logger()->success('All permissions set.');
}
}
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