Example #1
0
 protected function postProcessResponse(Response $response, Controller $controllerInstance)
 {
     if (!$response instanceof Renderable || !$this->isInstalled()) {
         return false;
     }
     $response->set('user', $controllerInstance->getUser()->toArray());
     $response->set('message', $controllerInstance->getMessage());
     $response->set('errorMessage', $controllerInstance->getErrorMessage());
     if ($controllerInstance instanceof FrontendController) {
         $response->set('currency', $controllerInstance->getRequestCurrency());
     }
     // fetch queued EAV data
     if (class_exists('ActiveRecordModel', false)) {
         ActiveRecordModel::loadEav();
     }
     $renderer = $this->getRenderer();
     if ($response instanceof ActionResponse && !$controllerInstance->isBlocksProcessed) {
         $controllerInstance->isBlocksProcessed = true;
         foreach ($renderer->getBlockConfiguration() as $object => $commands) {
             foreach ($commands as $command) {
                 if ($renderer->isBlock($object)) {
                     $action = $command['action'];
                     switch ($action['command']) {
                         case 'replace':
                             $action['command'] = 'append';
                             $controllerInstance->removeBlock($object);
                         case 'append':
                         case 'prepend':
                             if (!empty($action['isDefinedBlock'])) {
                                 $action = array_merge($action, (array) array_shift($controllerInstance->getBlocks($action['view'])));
                             }
                             $controllerInstance->addBlock($object, $action['call'], $action['view'], $action['command'] == 'prepend');
                             break;
                         case 'remove':
                             $controllerInstance->removeBlock($object);
                             break;
                         case 'theme':
                             $this->setTheme($action['view']);
                             break;
                     }
                 }
             }
         }
     }
 }