1 | <?php |
||
6 | class PdoRouteWebsiteFactory implements ContainerInterface |
||
7 | { |
||
8 | |||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | public $table = 'pages'; |
||
13 | |||
14 | /** |
||
15 | * @var \PDOStatement |
||
16 | */ |
||
17 | public $stmt; |
||
18 | |||
19 | /** |
||
20 | * @param PDO $pdo |
||
21 | * @param string $table Websites table name |
||
22 | * @param WebsiteAbstract $website Optional: Website template object |
||
23 | */ |
||
24 | public function __construct( \PDO $pdo, $table, WebsiteAbstract $website = null ) |
||
25 | { |
||
26 | $this->table = $table; |
||
27 | |||
28 | $sql = "SELECT |
||
29 | id, |
||
30 | title, |
||
31 | via, |
||
32 | route, |
||
33 | route_name, |
||
34 | content_file, |
||
35 | controller, |
||
36 | template, |
||
37 | dom_id, |
||
38 | javascripts, |
||
39 | stylesheets, |
||
40 | is_active |
||
41 | FROM {$this->table} |
||
42 | |||
43 | WHERE route_name = :route_name |
||
44 | LIMIT 1"; |
||
45 | |||
46 | $this->stmt = $pdo->prepare( $sql ); |
||
47 | $this->stmt->setFetchMode( \PDO::FETCH_CLASS, $website ? get_class($website) : Website::class ); |
||
48 | |||
49 | } |
||
50 | |||
51 | |||
52 | public function __invoke( $route_name ) |
||
56 | |||
57 | |||
58 | |||
59 | public function has ($route_name) { |
||
63 | |||
64 | |||
65 | public function get ($route_name) { |
||
90 | |||
91 | |||
92 | protected function executeStatement ($route_name) { |
||
104 | |||
105 | } |
||
106 | |||
107 |