mirror of
https://github.com/getgrav/grav.git
synced 2026-03-06 12:31:53 +01:00
Add accessLevels to return the used page access levels
This commit is contained in:
@@ -480,6 +480,29 @@ class Pages
|
||||
return static::types();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get access levels of the site pages
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function accessLevels()
|
||||
{
|
||||
$accessLevels = [];
|
||||
foreach($this->all() as $page) {
|
||||
if (isset($page->header()->access)) {
|
||||
if (is_array($page->header()->access)) {
|
||||
foreach($page->header()->access as $index => $accessLevel) {
|
||||
array_push($accessLevels, $index);
|
||||
}
|
||||
} else {
|
||||
array_push($accessLevels, $page->header()->access);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_unique($accessLevels);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available parents.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user