Reputation:
On my function I am trying to add the word admin here
$permission = 'admin' .'/'. strtolower(basename($file, '.php'));
But in my $ignore = array()
the controllers names do not get ignored.
$ignore = array(
'Dashboard',
'Admin',
'Logout',
'Not_found',
'Permission',
'Footer',
'Header',
'Navbar',
'Session_data'
);
Question when I add the word admin to the $permission =
how can I make it ignore the controllers names are that in the ignore array.
$ignore = array(
'Dashboard',
'Admin',
'Logout',
'Not_found',
'Permission',
'Footer',
'Header',
'Navbar',
'Session_data'
);
$data['permissions'] = array();
$files = glob(APPPATH . 'modules/admin/controllers/*/*.php');
foreach ($files as $file) {
$permission = 'admin' .'/'. strtolower(basename($file, '.php'));
if (!in_array($permission, $ignore)) {
$data['permissions'][] = $permission;
}
}
Upvotes: 0
Views: 43
Reputation: 542
You can modify foreach as this..
foreach ($files as $file) {
$permission = strtolower(basename($file, '.php'));
if (!in_array($permission, $ignore)) {
$data['permissions'][] = 'admin' .'/'. $permission;
}
}
Upvotes: 3