1: <?php
2:
3: /**
4: * Pry Framework
5: *
6: * LICENSE
7: *
8: * This source file is subject to the new BSD license that is bundled
9: * with this package in the file LICENSE.txt.
10: *
11: */
12:
13: namespace Pry\Controller;
14:
15: use Pry\Util\Registry;
16:
17: /**
18: * Controller de base fournissant les info essentielles aux autres controlleurs
19: * @category Pry
20: * @package Controller
21: * @version 1.2.0
22: * @author Olivier ROGER <oroger.fr>
23: */
24: abstract class BaseController
25: {
26:
27: /**
28: * Objet de vue
29: * @var mixed
30: */
31: protected $view;
32:
33: /**
34: * Requête utilisé pour atteindre le controller
35: * @var Net_Request
36: */
37: protected $request;
38:
39: /**
40: * Objet base de données
41: * @var Zend_Db_Adapter_Abstract
42: */
43: protected $db;
44:
45: /**
46: * Langue détectée dans l'URL. Code sur deux lettre
47: * @var string
48: */
49: protected $codeLangue;
50:
51: /**
52: * Instanciation du controller
53: * @param Net_Request $requete Requête utilisé
54: * @param string $codeLangue Code langue. par défaut défini à fr
55: */
56: public function __construct($requete, $codeLangue = 'fr')
57: {
58: if (Registry::isRegistered('Db'))
59: $this->db = Registry::get('Db');
60:
61: $this->request = $requete;
62: $this->codeLangue = $codeLangue;
63: }
64:
65: /**
66: * Redirection
67: * @param string $url
68: */
69: public function redirect($url)
70: {
71: header('Location: /' . $url);
72: exit;
73: }
74:
75: public function setView($view)
76: {
77: $this->view = $view;
78:
79: if ($this->view instanceof Pry\View\View)
80: $this->view->controller = $this->request->controller;
81: }
82:
83: abstract public function index();
84: }
85: