1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Containers\Web\Controller; |
4
|
|
|
|
5
|
|
|
use App\Containers\Web\Interface\TestInterface; |
6
|
|
|
use App\Containers\Web\WebController; |
7
|
|
|
use Rudra\EventDispatcher\EventDispatcherFacade as Dispatcher; |
8
|
|
|
|
9
|
|
|
use Rudra\Container\Interfaces\RudraInterface; |
10
|
|
|
use stdClass; |
11
|
|
|
|
12
|
|
|
class IndexController extends WebController |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @Routing(url = '') |
16
|
|
|
* @Routing(url = 'name/{name}') |
17
|
|
|
* |
18
|
|
|
* @Middleware(name = 'App\Containers\Web\Middleware\FirstMiddleware') |
19
|
|
|
* @Middleware(name = 'App\Containers\Web\Middleware\SecondMiddleware') |
20
|
|
|
* |
21
|
|
|
* @AfterMiddleware(name = 'App\Containers\Web\Middleware\FirstMiddleware') |
22
|
|
|
* @AfterMiddleware(name = 'App\Containers\Web\Middleware\SecondMiddleware') |
23
|
|
|
*/ |
24
|
|
|
public function annotations(string $name = 'John'): void |
25
|
|
|
{ |
26
|
|
|
data([ |
27
|
|
|
"content" => cache(['mainpage', 'now']) ?? view(["index", 'mainpage']), |
28
|
|
|
]); |
29
|
|
|
|
30
|
|
|
Dispatcher::dispatch('message', __CLASS__); |
31
|
|
|
$this->info("Hello $name"); |
32
|
|
|
|
33
|
|
|
Dispatcher::notify('one'); |
34
|
|
|
|
35
|
|
|
dump(__METHOD__); |
36
|
|
|
|
37
|
|
|
render("layout", data()); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
#[Routing(url: '')] |
41
|
|
|
#[Routing(url: 'name/:[\d]{1,3}')] |
42
|
|
|
#[Middleware(name: 'App\Containers\Web\Middleware\FirstMiddleware')] |
43
|
|
|
#[Middleware(name: 'App\Containers\Web\Middleware\SecondMiddleware')] |
44
|
|
|
#[AfterMiddleware(name: 'App\Containers\Web\Middleware\FirstMiddleware')] |
45
|
|
|
#[AfterMiddleware(name: 'App\Containers\Web\Middleware\SecondMiddleware')] |
46
|
|
|
public function attributes(string $name = 'John'): void |
47
|
|
|
{ |
48
|
|
|
data([ |
49
|
|
|
"content" => cache(['mainpage', 'now']) ?? view(["index", 'mainpage']), |
50
|
|
|
]); |
51
|
|
|
|
52
|
|
|
Dispatcher::dispatch('message', __CLASS__); |
53
|
|
|
$this->info("Hello $name"); |
54
|
|
|
|
55
|
|
|
Dispatcher::notify('one'); |
56
|
|
|
|
57
|
|
|
dump(__METHOD__); |
58
|
|
|
|
59
|
|
|
render("layout", data()); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
#[Routing(url: 'autowire')] |
63
|
|
|
public function autowire(RudraInterface $rudra, stdClass $std, TestInterface $test): void |
64
|
|
|
{ |
65
|
|
|
dd($rudra, $std, $test); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|