コード例 #1
0
 /**
  * testGetMessageForCode() expect the message with and without the code.
  */
 public function testGetMessageForCode()
 {
     $h = $this->object->getMessageForCode(404);
     $this->assertNotEmpty($h, 'Should be not empty for this code');
     $this->assertNotContains('404', $h, 'Should not contains the code with message');
     $h = $this->object->getMessageForCode(404, TRUE);
     $this->assertNotEmpty($h, 'Should be not empty for this code');
     $this->assertStringStartsWith('404', $h, 'Should contains the code with message : ' . $h);
 }
コード例 #2
0
 /**
  * The default indexAction to Agana's Rest controllers should not be called
  * returning a Bad Request.
  * The indexAction may be implemented when is needed a Rest and Tradicional controller 
  */
 public function indexAction()
 {
     $codeReturn = Agana_Http_StatusCodes::HTTP_BAD_REQUEST;
     $this->getResponse()->setHttpResponseCode($codeReturn);
     $this->getResponse()->setHeader('Message', Agana_Http_StatusCodes::getMessageForCode($codeReturn, true));
     $this->getResponse()->setBody('You should not access this service without a proper HTTP HEADER');
 }
コード例 #3
0
 public function getAction()
 {
     $response = $this->getResponse();
     $this->_helper->viewRenderer->setNoRender(true);
     $layout = Zend_Layout::getMvcInstance();
     $layout->disableLayout();
     if ($image = $this->_getImage()) {
         $domain = new Media_Domain_Image();
         $domain->setImage($image);
         $response->setHeader('Content-Type', $image->getMimetype());
         $size = $this->_hasParam('size') ? $this->_getParam('size') : '';
         $img = $domain->loadFile($size);
         $response->setBody($img);
     } else {
         $response->setHttpResponseCode(Agana_Http_StatusCodes::HTTP_NOT_FOUND);
         $response->setBody(Agana_Http_StatusCodes::getMessageForCode(Agana_Http_StatusCodes::HTTP_NOT_FOUND));
     }
 }