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