/** * Call */ public function call() { //print_r('--middlewareMQManager call()--'); $MQManagerConfigObject = new \Utill\MQ\MQManagerConfig(); $managerConfig = new \Zend\ServiceManager\Config($MQManagerConfigObject->getConfig()); $MQManager = new \Utill\MQ\MQManager($managerConfig); $MQManager->setService('slimApp', $this->app); $this->app->setMQManager($MQManager); //$test = $BLLManager->get('reportConfigurationBLL'); //print_r($test->getSlimApp()); $this->next->call(); }
/** * Run * * This method invokes the middleware stack, including the core Slim application; * the result is an array of HTTP status, header, and body. These three items * are returned to the HTTP client. */ public function run() { /** * set time zone for log and message queue message body * @author Mustafa Zeynel Dağlı */ date_default_timezone_set($this->container['settings']['time.zone']); /** * MQMAnager middle ware katmanından önce inject * ediliyor/ test amaçlı değiştirilecek */ $MQManagerConfigObject = new \Utill\MQ\MQManagerConfig(); $managerConfig = new \Zend\ServiceManager\Config($MQManagerConfigObject->getConfig()); $MQManager = new \Utill\MQ\MQManager($managerConfig); $MQManager->setService('slimApp', $this); $this->setMQManager($MQManager); set_error_handler(array('\\Slim\\Slim', 'handleErrors')); /** * MQmanager exceptions has been tested by changing error handler function * @author Zeynel Dağlı * @todo first tests did not work, after further tests if not work * this code can be removed */ //set_error_handler(array($this, 'handleErrorsCustom')); //Apply final outer middleware layers if ($this->config('debug')) { //Apply pretty exceptions only in debug to avoid accidental information leakage in production $this->add(new \Slim\Middleware\PrettyExceptions()); } /** * zeynel dağlı */ if ($this->container['settings']['log.level'] <= \Slim\Log::ERROR) { //print_r('--slim run kontrolor--'); $this->add(new \Slim\Middleware\PrettyExceptions()); } //Invoke middleware and application stack $this->middleware[0]->call(); //print_r('--slim run kontrolor2--'); /** * if rest service entry logging conf. true, publish to message queue * @since 07/12/2015 this functionality is being called from MQ manager * @author Mustafa Zeynel Dağlı */ //if($this->container['settings']['restEntry.rabbitMQ'] == true) $this->publishMessage(); if ($this->container['settings']['restEntry.rabbitMQ'] == true) { $this->getMQManager()->get('MQRestCallLog'); } //Fetch status, header, and body list($status, $headers, $body) = $this->response->finalize(); // Serialize cookies (with optional encryption) \Slim\Http\Util::serializeCookies($headers, $this->response->cookies, $this->settings); //Send headers if (headers_sent() === false) { //Send status if (strpos(PHP_SAPI, 'cgi') === 0) { header(sprintf('Status: %s', \Slim\Http\Response::getMessageForCode($status))); } else { header(sprintf('HTTP/%s %s', $this->config('http.version'), \Slim\Http\Response::getMessageForCode($status))); } //Send headers foreach ($headers as $name => $value) { $hValues = explode("\n", $value); foreach ($hValues as $hVal) { header("{$name}: {$hVal}", false); } } } //Send body, but only if it isn't a HEAD request if (!$this->request->isHead()) { echo $body; } $this->applyHook('slim.after'); restore_error_handler(); }