Contrôleur Galerie/View, 404 si galerie existe pas
[zf2.biz/galerie.git] / module / Galerie / src / Galerie / Controller / IndexController.php
index babaf28..66892fa 100644 (file)
@@ -34,11 +34,7 @@ class IndexController extends AbstractActionController
     public function indexAction() 
     { 
         return new ViewModel(array(
-            'Galerie_all' => $this->_getGalerieTable()->all(),
-            'Galerie_one' => $this->_getGalerieTable()->get(1),
-            'GalerieInfo_all' => $this->_getGalerieInfoTable()->select(),
-            'GalerieInfo_one' => $this->_getGalerieInfoTable()->select(array('gallery.id' => 1))->current(),
-            'GalerieInfo_usr' => $this->_getGalerieInfoTable()->select(array('gallery.id_user' => 1)),
+            'galeries' => $this->_getGalerieInfoTable()->all(),
         )); 
     } 
 
@@ -53,7 +49,16 @@ class IndexController extends AbstractActionController
     } 
 
     public function viewAction() 
-    { 
-        return array(); 
+    {
+        $galerie = $this->_getGalerieInfoTable()->any(
+            $this->params()->fromRoute('id', null)
+        );
+        if (!$galerie) {
+            $this->getResponse()->setStatusCode(404);
+            return;
+        }
+        return new ViewModel(array(
+            'galerie' => $galerie,
+        ));
     } 
 }