|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Routes; |
|
4
|
|
|
|
|
5
|
|
|
use CoffeeCode\Router\Router; |
|
6
|
|
|
use ThallesDella\FactoryRouter\Routes; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Factory Router | Class AAA [ EXAMPLE ] |
|
10
|
|
|
* |
|
11
|
|
|
* @category Examples\Routes |
|
12
|
|
|
* @package FactoryRouter\Examples\Routes |
|
13
|
|
|
* @author Thalles D. koester <[email protected]> |
|
14
|
|
|
* @license https://choosealicense.com/licenses/mit/ MIT |
|
15
|
|
|
* @link https://github.com/thallesdella/factory-router |
|
16
|
|
|
*/ |
|
17
|
|
|
class AAA extends Routes |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* main constructor. |
|
21
|
|
|
* |
|
22
|
|
|
* @param Router $router Router object |
|
23
|
|
|
*/ |
|
24
|
|
|
public function __construct(Router $router) |
|
25
|
|
|
{ |
|
26
|
|
|
parent::__construct($router, 'Website'); |
|
27
|
|
|
$this->namespace('Controllers'); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @return Router |
|
32
|
|
|
*/ |
|
33
|
|
|
public function updateRouter(): Router |
|
34
|
|
|
{ |
|
35
|
|
|
$this->main(); |
|
36
|
|
|
$this->categories(); |
|
37
|
|
|
$this->posts(); |
|
38
|
|
|
$this->user(); |
|
39
|
|
|
$this->error(); |
|
40
|
|
|
return $this->router; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @return void |
|
45
|
|
|
*/ |
|
46
|
|
|
private function main(): void |
|
47
|
|
|
{ |
|
48
|
|
|
$this->group(null); |
|
49
|
|
|
|
|
50
|
|
|
$this->get("/", "home"); |
|
51
|
|
|
$this->get("/{search}", "search"); |
|
52
|
|
|
$this->get("/contato", "contact"); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @return void |
|
57
|
|
|
*/ |
|
58
|
|
|
private function categories(): void |
|
59
|
|
|
{ |
|
60
|
|
|
$this->group('cat'); |
|
61
|
|
|
|
|
62
|
|
|
$this->get("/", "categories"); |
|
63
|
|
|
$this->get("/{cat_name}", "category"); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @return void |
|
68
|
|
|
*/ |
|
69
|
|
|
private function posts(): void |
|
70
|
|
|
{ |
|
71
|
|
|
$this->group('posts'); |
|
72
|
|
|
|
|
73
|
|
|
$this->get("/", "posts"); |
|
74
|
|
|
$this->get("/{post_name}", "post"); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @return void |
|
79
|
|
|
*/ |
|
80
|
|
|
private function user(): void |
|
81
|
|
|
{ |
|
82
|
|
|
$this->group('me'); |
|
83
|
|
|
|
|
84
|
|
|
$this->get("/", "login"); |
|
85
|
|
|
$this->router->get('/{msg}', "Website:login", "website.login.msg"); |
|
86
|
|
|
|
|
87
|
|
|
$this->get("/registrar", "register"); |
|
88
|
|
|
$this->get("/recuperar", "forget"); |
|
89
|
|
|
$this->get("/resetar", "reset"); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @return void |
|
94
|
|
|
*/ |
|
95
|
|
|
private function error(): void |
|
96
|
|
|
{ |
|
97
|
|
|
$this->group('error'); |
|
98
|
|
|
$this->get('/{code}', 'error'); |
|
99
|
|
|
} |
|
100
|
|
|
} |