コード例 #1
0
ファイル: NotFoundResponse.php プロジェクト: splot/framework
 /**
  * Constructor.
  * 
  * @param string $content Content.
  * @param int $status [optional] Response status code. Default: 404.
  * @param array $headers [optional] Headers array.
  */
 public function __construct($content = '', $status = 404, $headers = array())
 {
     if (!is_array($headers)) {
         throw new InvalidArgumentException('array', $headers, 3);
     }
     parent::__construct($content, $status, $headers);
 }
コード例 #2
0
ファイル: RedirectResponse.php プロジェクト: splot/framework
 /**
  * Constructor.
  * 
  * @param string $url URL to redirect to.
  * @param int $status [optional] Response status code. Default: 302.
  * @param array $headers [optional] Headers array.
  */
 public function __construct($url = '', $status = 302, $headers = array())
 {
     if (empty($url)) {
         throw new InvalidArgumentException('non-empty string', $url);
     }
     if (!is_array($headers)) {
         throw new InvalidArgumentException('array', $headers, 3);
     }
     parent::__construct('', $status, array('Location' => $url));
     $this->url = $url;
 }
コード例 #3
0
ファイル: JsonResponse.php プロジェクト: splot/framework
 /**
  * Sends content for the current web response.
  *
  * @return JsonResponse
  */
 public function sendContent()
 {
     $this->content = $this->getContent();
     return parent::sendContent();
 }
コード例 #4
0
 /**
  * Renders the final response and sends it back to the client.
  * 
  * @param Response $response HTTP Response to be sent.
  * @param Request $request The original HTTP request for context.
  */
 public function sendResponse(Response $response, Request $request)
 {
     // prepare the response for sending (will tweak some headers based on the request)
     $response->prepare($request);
     // trigger WillSendResponse event for any last minute changes
     $this->container->get('event_manager')->trigger(new WillSendResponse($response, $request));
     $timer = $this->container->get('splot.timer');
     $time = $timer->getDuration();
     $memory = $timer->getCurrentMemoryPeak();
     $memoryString = StringUtils::bytesToString($memory);
     $this->logger->debug('Rendering response for {method} {uri} took {time} ms and used {memory} memory.', array('method' => $request->getMethod(), 'uri' => $request->getRequestUri(), 'memory' => $memoryString, 'time' => $time, '@stat' => 'splot.render', '@time' => $time, '@memory' => $memory));
     // and finally send out the response
     $response->send();
 }
コード例 #5
0
ファイル: ResponseTest.php プロジェクト: splot/framework
 /**
  * @expectedException \MD\Foundation\Exceptions\InvalidArgumentException
  * @covers ::alterPart
  */
 public function testInvalidAlterPart()
 {
     $response = new Response('Lorem ipsum dolor sit amet, adipiscit elit!');
     $response->alterPart('', 'Lipsum');
 }