Backend\Core\Engine\Base\Object::setAction PHP Method

setAction() public method

Set the action
public setAction ( string $action, string $module = null )
$action string The action to load.
$module string The module to load.
    public function setAction($action, $module = null)
    {
        // set module
        if ($module !== null) {
            $this->setModule($module);
        }
        // check if module is set
        if ($this->getModule() === null) {
            throw new Exception('Module has not yet been set.');
        }
        // is this action allowed?
        if (!Authentication::isAllowedAction($action, $this->getModule())) {
            // set correct headers
            header('HTTP/1.1 403 Forbidden');
            // throw exception
            throw new Exception('Action not allowed.');
        }
        // set property
        $this->action = (string) \SpoonFilter::toCamelCase($action);
    }