2
2
namespace Drush \Drupal \Commands \core ;
3
3
4
4
use Consolidation \OutputFormatters \Options \FormatterOptions ;
5
+ use Consolidation \SiteAlias \SiteAliasManagerAwareTrait ;
5
6
use Drupal \user \Entity \Role ;
6
7
use Drush \Commands \DrushCommands ;
7
8
use Consolidation \OutputFormatters \StructuredData \RowsOfFields ;
9
+ use Drush \Drush ;
10
+ use Drush \SiteAlias \SiteAliasManagerAwareInterface ;
11
+ use Drush \Utils \StringUtils ;
8
12
9
- class RoleCommands extends DrushCommands
13
+ class RoleCommands extends DrushCommands implements SiteAliasManagerAwareInterface
10
14
{
15
+ use SiteAliasManagerAwareTrait;
16
+
11
17
/**
12
18
* Create a new role.
13
19
*
@@ -58,7 +64,6 @@ public function delete($machine_name)
58
64
* @validate-permissions permissions
59
65
* @param $machine_name The role to modify.
60
66
* @param $permissions The list of permission to grant, delimited by commas.
61
- * @option cache-clear Set to 0 to suppress normal cache clearing; the caller should then clear if needed.
62
67
* @usage drush role-add-perm anonymous 'post comments'
63
68
* Allow anon users to post comments.
64
69
* @usage drush role:add-perm anonymous "'post comments','access content'"
@@ -69,10 +74,10 @@ public function delete($machine_name)
69
74
*/
70
75
public function roleAddPerm ($ machine_name , $ permissions )
71
76
{
72
- $ perms = _convert_csv_to_array ($ permissions );
77
+ $ perms = StringUtils:: csvToArray ($ permissions );
73
78
user_role_grant_permissions ($ machine_name , $ perms );
74
79
$ this ->logger ()->success (dt ('Added "!permissions" to "!role" ' , ['!permissions ' => $ permissions , '!role ' => $ machine_name ]));
75
- drush_drupal_cache_clear_all ( );
80
+ Drush:: drush ( $ this -> siteAliasManager ()-> getSelf (), ' cache-rebuild ' );
76
81
}
77
82
78
83
/**
@@ -83,17 +88,16 @@ public function roleAddPerm($machine_name, $permissions)
83
88
* @validate-permissions permissions
84
89
* @param $machine_name The role to modify.
85
90
* @param $permissions The list of permission to grant, delimited by commas.
86
- * @option cache-clear Set to 0 to suppress normal cache clearing; the caller should then clear if needed.
87
91
* @usage drush role:remove-perm anonymous 'access content'
88
92
* Hide content from anon users.
89
93
* @aliases rmp,role-remove-perm
90
94
*/
91
95
public function roleRemovePerm ($ machine_name , $ permissions )
92
96
{
93
- $ perms = _convert_csv_to_array ($ permissions );
97
+ $ perms = StringUtils:: csvToArray ($ permissions );
94
98
user_role_revoke_permissions ($ machine_name , $ perms );
95
99
$ this ->logger ()->success (dt ('Removed "!permissions" to "!role" ' , ['!permissions ' => $ permissions , '!role ' => $ machine_name ]));
96
- drush_drupal_cache_clear_all ( );
100
+ Drush:: drush ( $ this -> siteAliasManager ()-> getSelf (), ' cache-rebuild ' );
97
101
}
98
102
99
103
/**
0 commit comments