/** * Metod called to dispatch an action. */ public function dispatch($action) { $action = strtolower($action); if ($this->assets->provides('events', '\\Proem\\Signal\\Manager\\Template')) { $this->assets->get('events')->trigger((new Bootstrap('proem.pre.action.' . $action))->setServiceManager($this->assets)); } $method = $action . 'Action'; $result = $this->{$method}(); if ($this->assets->provides('events', '\\Proem\\Signal\\Manager\\Template')) { $this->assets->get('events')->trigger((new Bootstrap('proem.post.action.' . $action))->setServiceManager($this->assets)); } return $result; }
/** * Dispatch the current controller stored within * the $class property. * * Prior to dispatch this method will add any params * present in the payload to the *request* object stored * within the service manager. * * It will then execute the controllers preAction method, the action * method provided by the payload, then postAction. * * @return Proem\Api\Dispatch\Standard */ public function dispatch() { if ($this->assets->has('request') && $this->payload->get('params') && is_array($this->payload->get('params'))) { $this->assets->get('request')->setGetData($this->payload->get('params')); } $this->class->dispatch($this->action); return $this; }
/** * Initialise the boostrap process * * This simple call will start the filter chain in motion * * @param string|null $environment */ public function init($environment = null) { $this->serviceManager->set('events', $this->events); $this->events->get()->trigger((new Bootstrap('proem.init'))->setServiceManager($this->serviceManager)->setEnvironment($environment), function ($response) { if ($response instanceof Proem\Filter\Manager\Template) { $this->filterManager = $response; } }); if ($this->filterManager === null) { $this->filterManager = new FilterManager(); } $this->filterManager->setServiceManager($this->serviceManager)->attachEvent(new Response(), FilterManager::RESPONSE_EVENT_PRIORITY)->attachEvent(new Request(), FilterManager::REQUEST_EVENT_PRIORITY)->attachEvent(new Route(), FilterManager::ROUTE_EVENT_PRIORITY)->attachEvent(new Dispatch(), FilterManager::DISPATCH_EVENT_PRIORITY)->init(); }