FOF30\Controller\Controller::getACLRuleFor PHP Method

getACLRuleFor() protected method

Resolves @task and &callback notations for ACL privileges
protected getACLRuleFor ( string $area, array $oldAreas = [] ) : mixed
$area string The task notation to resolve
$oldAreas array Areas we've already been redirected from, used to detect circular references
return mixed The resolved ACL privilege
    protected function getACLRuleFor($area, $oldAreas = array())
    {
        // If it's a &notation return the callback result
        if (substr($area, 0, 1) == '&') {
            $method = substr($area, 1);
            // Method not found? Assume true.
            if (!method_exists($this, $method)) {
                return true;
            }
            return $this->{$method}();
        }
        // If it's not an @notation return the raw string
        if (substr($area, 0, 1) != '@') {
            return $area;
        }
        // Get the array index (other task)
        $index = substr($area, 1);
        // If the referenced task has no ACL map, return true
        if (!isset($this->taskPrivileges[$index])) {
            return true;
        }
        // Get the new ACL area
        $newArea = $this->taskPrivileges[$index];
        $oldAreas[] = $area;
        // Circular reference found
        if (in_array($newArea, $oldAreas)) {
            return true;
        }
        // We've found an ACL privilege. Return it.
        if (substr($area, 0, 1) != '@') {
            return $newArea;
        }
        // We have another reference. Resolve it.
        return $this->getACLRuleFor($newArea, $oldAreas);
    }