Frontend\Core\Engine\Ajax::setAction PHP Method

setAction() public method

Set action
public setAction ( string $value )
$value string The action that should be executed.
    public function setAction($value)
    {
        // check if module is set
        if ($this->getModule() === null) {
            throw new Exception('Module has not yet been set.');
        }
        // grab the file
        $finder = new Finder();
        $finder->name($value . '.php');
        if ($this->getModule() == 'core') {
            $finder->in(FRONTEND_PATH . '/Core/Ajax/');
        } else {
            $finder->in(FRONTEND_PATH . '/Modules/' . $this->getModule() . '/Ajax/');
        }
        // validate
        if (count($finder->files()) != 1) {
            throw new Exception('Action not correct.');
        }
        // set property
        $this->action = (string) $value;
    }