/**
  * {@inheritdoc}
  */
 public function render(int $statusCode, array $headers, $data) : string
 {
     $json = parent::render($statusCode, $headers, $data);
     if (is_string($json)) {
         $json = json_encode($json);
     }
     $out = '{"code":' . $statusCode . ',"data":' . $json . ',"headers":' . json_encode($headers) . '}';
     return $out;
 }
 public function beforeAction($a)
 {
     if (!Yii::app()->params['ApiKey']) {
         Json::render(array('result' => 'failed', 'description' => 'ApiKey not configured'));
     } elseif (Yii::app()->request->getParam('key') !== md5(Yii::app()->params['ApiKey'] . Yii::app()->request->getParam('rand_param'))) {
         Json::render(array('result' => 'failed', 'description' => 'ApiKey not valid'));
     } else {
         return true;
     }
 }