output() public method

Outputs an answer to the browser
public output ( integer $statusCode, mixed $data = null, string $message = null )
$statusCode integer The status code to use, use one of the available constants (self::OK, self::BAD_REQUEST, self::FORBIDDEN, self::ERROR).
$data mixed The data to be returned (will be encoded as JSON).
$message string A text-message.
示例#1
0
 /**
  * Set module
  *
  * @param string $value The module, wherefore an action will be executed.
  */
 public function setModule($value)
 {
     // get the possible modules
     $possibleModules = Model::getModules();
     // validate
     if (!in_array($value, $possibleModules)) {
         // create fake action
         $fakeAction = new FrontendBaseAJAXAction($this->getKernel(), '', '');
         // output error
         $fakeAction->output(FrontendBaseAJAXAction::BAD_REQUEST, null, 'Module not correct.');
     }
     // set property
     $this->module = (string) $value;
 }