public function beforeRun()
 {
     $this->request = Request::createFromGlobals(false);
     $this->response = new Response();
     if (!$this->authenticate()) {
         $msg = new Message();
         $msg->setSuccess(false)->addError('Wrong authentication hash');
         return $this->respondMessage($msg);
     }
 }
Exemple #2
0
 /**
  * @param string $data
  * @return Message
  */
 protected function decode($data)
 {
     $return = new Message();
     if (!($decodedData = json_decode($data, true))) {
         $return->addError('Cannot parse data to JSON: ' . print_r($data, true));
     } else {
         $return->initFromData($decodedData);
     }
     // MK: wykomentowalem, bo to ingoruje "success: 0" bez errorow
     //return $return->setSuccess(!$return->hasErrors());
     //jesli byl ustawiony success=0, ale brak errorow - dodaj domyslny
     if (!$return->isValid() && !$return->hasErrors()) {
         $return->addError('Decoded message is not valid, but no errors were set');
     }
     return $return;
 }