[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Part of the Joomla Framework Application Package 4 * 5 * @copyright Copyright (C) 2005 - 2021 Open Source Matters, Inc. All rights reserved. 6 * @license GNU General Public License version 2 or later; see LICENSE 7 */ 8 9 namespace Joomla\Application; 10 11 use Joomla\Application\Controller\ControllerResolverInterface; 12 use Joomla\Input\Input; 13 use Joomla\Registry\Registry; 14 use Joomla\Router\RouterInterface; 15 use Psr\Http\Message\ResponseInterface; 16 17 /** 18 * A basic web application class for handing HTTP requests. 19 * 20 * @since 2.0.0 21 */ 22 class WebApplication extends AbstractWebApplication implements SessionAwareWebApplicationInterface 23 { 24 use SessionAwareWebApplicationTrait; 25 26 /** 27 * The application's controller resolver. 28 * 29 * @var ControllerResolverInterface 30 * @since 2.0.0 31 */ 32 protected $controllerResolver; 33 34 /** 35 * The application's router. 36 * 37 * @var RouterInterface 38 * @since 2.0.0 39 */ 40 protected $router; 41 42 /** 43 * Class constructor. 44 * 45 * @param ControllerResolverInterface $controllerResolver The application's controller resolver 46 * @param RouterInterface $router The application's router 47 * @param Input $input An optional argument to provide dependency injection for the application's 48 * input object. If the argument is an Input object that object will become 49 * the application's input object, otherwise a default input object is 50 * created. 51 * @param Registry $config An optional argument to provide dependency injection for the application's 52 * config object. If the argument is a Registry object that object will 53 * become the application's config object, otherwise a default config object 54 * is created. 55 * @param Web\WebClient $client An optional argument to provide dependency injection for the application's 56 * client object. If the argument is a Web\WebClient object that object will 57 * become the application's client object, otherwise a default client object 58 * is created. 59 * @param ResponseInterface $response An optional argument to provide dependency injection for the application's 60 * response object. If the argument is a ResponseInterface object that object 61 * will become the application's response object, otherwise a default response 62 * object is created. 63 * 64 * @since 2.0.0 65 */ 66 public function __construct( 67 ControllerResolverInterface $controllerResolver, 68 RouterInterface $router, 69 Input $input = null, 70 Registry $config = null, 71 Web\WebClient $client = null, 72 ResponseInterface $response = null 73 ) 74 { 75 $this->controllerResolver = $controllerResolver; 76 $this->router = $router; 77 78 // Call the constructor as late as possible (it runs `initialise`). 79 parent::__construct($input, $config, $client, $response); 80 } 81 82 /** 83 * Method to run the application routines. 84 * 85 * @return void 86 * 87 * @since 2.0.0 88 */ 89 protected function doExecute(): void 90 { 91 $route = $this->router->parseRoute($this->get('uri.route'), $this->input->getMethod()); 92 93 // Add variables to the input if not already set 94 foreach ($route->getRouteVariables() as $key => $value) 95 { 96 $this->input->def($key, $value); 97 } 98 99 \call_user_func($this->controllerResolver->resolve($route)); 100 } 101 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |