From 8bd8f746674c0992e71e1a6952d0d37580291930 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20CHAZALLET?= Date: Wed, 7 Nov 2012 14:45:24 +0100 Subject: [PATCH] =?utf8?q?Mise=20au=20point=20du=20contr=C3=B4leur=20Galerie?= =?utf8?q?/index?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/Galerie/Controller/IndexController.php | 6 +--- .../Galerie/src/Galerie/Model/GalerieInfoTable.php | 33 ++++++++++++++++++++ module/Galerie/view/galerie/index/index.phtml | 24 ++------------ 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/module/Galerie/src/Galerie/Controller/IndexController.php b/module/Galerie/src/Galerie/Controller/IndexController.php index babaf28..2f28c98 100644 --- a/module/Galerie/src/Galerie/Controller/IndexController.php +++ b/module/Galerie/src/Galerie/Controller/IndexController.php @@ -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)), + 'all' => $this->_getGalerieInfoTable()->all(), )); } diff --git a/module/Galerie/src/Galerie/Model/GalerieInfoTable.php b/module/Galerie/src/Galerie/Model/GalerieInfoTable.php index 2acd45d..3696821 100644 --- a/module/Galerie/src/Galerie/Model/GalerieInfoTable.php +++ b/module/Galerie/src/Galerie/Model/GalerieInfoTable.php @@ -87,4 +87,37 @@ class GalerieInfoTable implements TableGatewayInterface throw new \Exception('delete is not allowed'); } + public function all() + { + return $this->select(); + } + + public function one($id) + { + if ($id === null) { + $row = null; + } else { + $row = $this->select(array('gallery.id' => (int) $id))->current(); + } + if (!$row) { + throw new \Exception("cannot get row {id: {$id}} in table 'galerie'"); + } + return $row; + } + + public function any($id) + { + if ($id === null) { + $row = null; + } else { + $row = $this->select(array('gallery.id' => (int) $id))->current(); + } + return $row; + } + + public function all_by_user($id_user) + { + return $this->select(array('gallery.id_user' => (int) $id_user)); + } + } diff --git a/module/Galerie/view/galerie/index/index.phtml b/module/Galerie/view/galerie/index/index.phtml index b32b282..bf934a6 100644 --- a/module/Galerie/view/galerie/index/index.phtml +++ b/module/Galerie/view/galerie/index/index.phtml @@ -2,26 +2,8 @@

Galerie

-

test de fetchAll()

- -
count(); ?>
-
toArray()); ?>
- -

test de getGalerie

- -
-

Identifiant : id; ?>

- - -

GalerieInfo

-

test de select()

- -
count(); ?>
-
toArray()); ?>
- -
- -
count(); ?>
-
toArray()); ?>
+

test de la méthode all()

+
count(); ?>
+
toArray()); ?>
-- 1.7.10.4