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