Created
April 13, 2016 09:39
-
-
Save Zegnat/c9224e81098e68079f08e670a93a84ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Send JSON encoded data to the browser and end all further processing. | |
* @method endWithJson | |
* @param array $data A data array. | |
* @throws InvalidArgumentException | |
* @return void | |
*/ | |
private function endWithJson($data) | |
{ | |
if (!is_array($data)) { | |
throw new \InvalidArgumentException('Method endWithJson requires a data array as argument.'); | |
} | |
header('Content-type: application/json'); | |
Yii::app()->end(json_encode($data)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment