Permalink
Browse files

Change status

  • Loading branch information...
1 parent c1f5a05 commit aec9a8968f02f0a37f29461777c182332915ad9f @Bukarinov Bukarinov committed Nov 26, 2012
Showing with 12 additions and 4 deletions.
  1. +12 −4 library/GeometriaLab/Api/Mvc/View/Http/CreateApiModelListener.php
@@ -4,15 +4,13 @@
use GeometriaLab\Model\ModelInterface,
GeometriaLab\Model\CollectionInterface,
- GeometriaLab\Model\Schema\SchemaInterface,
GeometriaLab\Api\Mvc\View\Model\ApiModel,
GeometriaLab\Api\Paginator\ModelPaginator,
- GeometriaLab\Api\Exception\InvalidFieldsException,
- GeometriaLab\Api\Mvc\Controller\Action\Params\AbstractParams,
- GeometriaLab\Api\Mvc\Controller\Action\Params\Schema\Property\IntegerProperty as ParamsIntegerProperty;
+ GeometriaLab\Api\Exception\InvalidFieldsException;
use Zend\Mvc\MvcEvent as ZendMvcEvent,
Zend\Mvc\View\Http\InjectViewModelListener as ZendInjectViewModelListener,
+ Zend\Http\PhpEnvironment\Response,
Zend\EventManager\ListenerAggregateInterface as ZendListenerAggregateInterface,
Zend\EventManager\EventManagerInterface as ZendEvents,
Zend\Validator\LessThan as ZendLessThanValidator,
@@ -78,9 +76,19 @@ public function createApiModel(ZendMvcEvent $e)
$apiModel->setVariable(ApiModel::FIELD_DATA, null);
}
+ /* @var Response $response */
$response = $e->getResponse();
$apiException = $e->getParam('apiException', false);
+ if ($response->getStatusCode() === Response::STATUS_CODE_200) {
+ if ($apiModel->getVariable(ApiModel::FIELD_DATA) === null) {
+ $response->setStatusCode(Response::STATUS_CODE_204);
+ }
+ if ($e->getRouteMatch()->getParam('action') === 'create') {
+ $response->setStatusCode(Response::STATUS_CODE_201);
+ }
+ }
+
// set http code
$httpCode = $response->getStatusCode();
$apiModel->setVariable(ApiModel::FIELD_HTTPCODE, $httpCode);

0 comments on commit aec9a89

Please sign in to comment.