Hi,
-I'm wondering what's the best way
1)
public function get($id)
    {
        $entity = $this->getMapper()->fetchById($id);
        if(is_bool($entity) && !$entity){
            return $this->getResponse()->setStatusCode(404); 
        }
        return new JsonModel(array(
               'status'=>200,
                'data' => $entity->toArray()
             )
        ));
    }
2)
public function get($id)
    {
        $entity = $this->getMapper()->fetchById($id);
        if(is_bool($entity) && !$entity){
            $this->getResponse()->setStatusCode(404);
            return new JsonModel(array(
                array(
                    'status' => 404,
                    'error'=>'Not Found')
            ));
        }
        return new JsonModel(array(
            array(
                'status'=>200,
                'data' => $entity->toArray()
                )
        ));
    }

-Is it possible manage it by the model ?
-Is there a way to avoid this
{"0":{"status":404,"error":"Not Found"},"message":"Page not
found.","reason":"error-controller-cannot-dispatch","display_exceptions":true,"controller":"FbswitRest\\Controller\\PhotoController","controller_class":null}
an get only
[{"status":404,"error":"Not Found"},"message":"Page not found."}]

Thanks in advance.





--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/AbstractRestfulController-not-found-resource-best-way-tp4660975.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com


Reply via email to