3fd3a474b9ff8f1256723caad24a74026b7004de
[zf2.biz/galerie.git] / module / Galerie / src / Galerie / Controller / IndexController.php
1 <?php
2
3 namespace Galerie\Controller; 
4
5 use Zend\Mvc\Controller\AbstractActionController; 
6 use Zend\View\Model\ViewModel;
7
8 class IndexController extends AbstractActionController 
9 {
10
11     private $_galerieTable;
12     private $_galerieInfoTable;
13
14
15     private function _getGalerieTable()
16     {
17         if (!$this->_galerieTable) {
18             $sm = $this->getServiceLocator();
19             $this->_galerieTable = $sm->get('Galerie\Model\GalerieTable');
20         }
21         return $this->_galerieTable;
22     }
23
24     private function _getGalerieInfoTable()
25     {
26         if (!$this->_galerieInfoTable) {
27             $sm = $this->getServiceLocator();
28             $this->_galerieInfoTable = $sm->get('Galerie\Model\GalerieInfoTable');
29         }
30         return $this->_galerieInfoTable;
31     }
32
33
34     public function indexAction() 
35     { 
36         return new ViewModel(array(
37             'galeries' => $this->_getGalerieInfoTable()->all(),
38         )); 
39     } 
40
41     public function editAction() 
42     { 
43         return array(); 
44     } 
45
46     public function delAction() 
47     { 
48         return array(); 
49     } 
50
51     public function viewAction() 
52     { 
53         return new ViewModel(array(
54             'galerie' => $this->_getGalerieInfoTable()->one(
55                 $this->params()->fromRoute('id', null)
56             ),
57         )); 
58     } 
59