Esempio n. 1
0
 /**
  * Decodes raw body in this request and returns it as a PHP array (after being
  * encoded as JSON).
  *
  * @see \Fine47\Util\Json::encode()
  * @return array|FALSE JSON-encoded result, FALSE on error
  */
 public function getBody()
 {
     // Get body.
     $body = parent::getBody();
     // First time decoding.
     if (!$this->decoded) {
         // Decode body and save as JSON.
         $body = Json::decode($body);
         // Save new body in its JSON representation.
         $this->setBody($body);
     }
     return $body;
 }
Esempio n. 2
0
 /**
  * Class constructor. Initial data is retrieved by calling toString().
  *
  * @param string $data initial flash data
  */
 public function __construct($data)
 {
     if ($data) {
         // Flash data is stored in base64.
         $data = Base64::decode($data);
         // And then encoded as JSON.
         if ($data) {
             $data = Json::decode($data);
         }
     }
     // Set initial flash details.
     $this->flash = !$data ? [] : $data;
     $this->newFlash = [];
 }
Esempio n. 3
0
 /**
  * Decodes the query's body and return it as JSON object.
  *
  * @param \Fine47\MicroRouter\Interfaces\Query $query to decode
  * @return array|FALSE decoded JSON data, FALSE on error
  */
 protected function getQueryData(Interfaces\Query $query)
 {
     return Util\Json::decode($query->getRawBody());
 }