/** * Get / Set the context * @param Ac_Context $context The new context * @return Ac_Context */ public static function &context(Ac_Context &$context = null) { if (!empty($context)) { self::$context = $context; } return self::$context; }
<div class="row ac-debug"> <div class="span6"> <h2>Request</h2> <table class="table table-striped table-condensed"> <?php $vars = Ac::context()->toArray(); foreach ($vars as $i => $v) { ?> <tr> <th><?php echo $i; ?> </th> <td><?php if ($v === true) { echo '<em>true</em>'; } elseif ($v === false) { echo '<em>false</em>'; } elseif ($v === null) { echo '<em>null</em>'; } else { echo print_r($v, true); } ?> </td> </tr> <?php } ?> </table> </div>
/** * Get and set status * @param int|null $status * @param string $httpVersion * @return int */ public function status($status = null, $httpVersion = null) { if (func_num_args() > 0) { if (!in_array(intval($status), array_keys(self::$messages))) { throw new InvalidArgumentException('Cannot set Response status. Provided status code "' . $status . '" is not a valid HTTP response code.'); } $this->status = (int) $status; if (strpos(PHP_SAPI, 'cgi') !== false) { //Send Status header if running with fastcgi $this->header("Status", $this->status); } else { if (empty($httpVersion)) { $httpVersion = Ac::context()->version; } $this->header("HTTP/" . $httpVersion, $this->status); //Else send HTTP message $this->header(sprintf('HTTP/%s %s', $httpVersion, $this->getStatusMessage())); } } return $this->status; }