| Total Complexity | 50 |
| Total Lines | 638 |
| Duplicated Lines | 0 % |
| Changes | 26 | ||
| Bugs | 1 | Features | 0 |
Complex classes like Jaxon often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Jaxon, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 64 | class Jaxon implements LoggerAwareInterface |
||
| 65 | { |
||
| 66 | use LoggerAwareTrait; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Package version number |
||
| 70 | * |
||
| 71 | * @const string |
||
| 72 | */ |
||
| 73 | const VERSION = 'Jaxon 4.0.0-dev'; |
||
| 74 | |||
| 75 | /* |
||
| 76 | * Request plugins |
||
| 77 | */ |
||
| 78 | const CALLABLE_CLASS = 'CallableClass'; |
||
| 79 | const CALLABLE_DIR = 'CallableDir'; |
||
| 80 | const CALLABLE_FUNCTION = 'CallableFunction'; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * A static instance on this class |
||
| 84 | * |
||
| 85 | * @var Jaxon |
||
| 86 | */ |
||
| 87 | private static $xInstance = null; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * The DI container |
||
| 91 | * |
||
| 92 | * @var Container |
||
| 93 | */ |
||
| 94 | private static $xContainer = null; |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @var Config |
||
| 98 | */ |
||
| 99 | protected $xConfig; |
||
| 100 | |||
| 101 | /** |
||
| 102 | * @var Translator |
||
| 103 | */ |
||
| 104 | protected $xTranslator; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @var ConfigReader |
||
| 108 | */ |
||
| 109 | protected $xConfigReader; |
||
| 110 | |||
| 111 | /** |
||
| 112 | * @var PluginManager |
||
| 113 | */ |
||
| 114 | protected $xPluginManager; |
||
| 115 | |||
| 116 | /** |
||
| 117 | * @var CodeGenerator |
||
| 118 | */ |
||
| 119 | protected $xCodeGenerator; |
||
| 120 | |||
| 121 | /** |
||
| 122 | * @var CallableRegistry |
||
| 123 | */ |
||
| 124 | protected $xCallableRegistry; |
||
| 125 | |||
| 126 | /** |
||
| 127 | * @var RequestHandler |
||
| 128 | */ |
||
| 129 | protected $xRequestHandler; |
||
| 130 | |||
| 131 | /** |
||
| 132 | * @var ResponseManager |
||
| 133 | */ |
||
| 134 | protected $xResponseManager; |
||
| 135 | |||
| 136 | /** |
||
| 137 | * @return void |
||
| 138 | */ |
||
| 139 | private static function initInstance() |
||
| 140 | { |
||
| 141 | // Save the Jaxon instance in the DI |
||
| 142 | self::$xContainer->val(Jaxon::class, self::$xInstance); |
||
| 143 | // Set the attributes from the container |
||
| 144 | self::$xInstance->xConfig = self::$xContainer->g(Config::class); |
||
| 145 | self::$xInstance->xTranslator = self::$xContainer->g(Translator::class); |
||
| 146 | self::$xInstance->xConfigReader = self::$xContainer->g(ConfigReader::class); |
||
| 147 | self::$xInstance->xPluginManager = self::$xContainer->g(PluginManager::class); |
||
| 148 | self::$xInstance->xCodeGenerator = self::$xContainer->g(CodeGenerator::class); |
||
| 149 | self::$xInstance->xCallableRegistry = self::$xContainer->g(CallableRegistry::class); |
||
| 150 | self::$xInstance->xRequestHandler = self::$xContainer->g(RequestHandler::class); |
||
| 151 | self::$xInstance->xResponseManager = self::$xContainer->g(ResponseManager::class); |
||
| 152 | } |
||
| 153 | |||
| 154 | /** |
||
| 155 | * Get the static instance |
||
| 156 | * |
||
| 157 | * @return Jaxon |
||
| 158 | */ |
||
| 159 | public static function getInstance(): ?Jaxon |
||
| 160 | { |
||
| 161 | if(self::$xInstance === null) |
||
| 162 | { |
||
| 163 | self::$xContainer = new Container(self::getDefaultOptions()); |
||
| 164 | self::$xInstance = new Jaxon(); |
||
| 165 | self::initInstance(); |
||
| 166 | } |
||
| 167 | return self::$xInstance; |
||
| 168 | } |
||
| 169 | |||
| 170 | /** |
||
| 171 | * The constructor |
||
| 172 | */ |
||
| 173 | private function __construct() |
||
| 174 | { |
||
| 175 | // Set the default logger |
||
| 176 | $this->setLogger(new NullLogger()); |
||
| 177 | } |
||
| 178 | |||
| 179 | /** |
||
| 180 | * The current Jaxon version |
||
| 181 | * |
||
| 182 | * @return string |
||
| 183 | */ |
||
| 184 | public function getVersion(): string |
||
| 185 | { |
||
| 186 | return self::VERSION; |
||
| 187 | } |
||
| 188 | |||
| 189 | /** |
||
| 190 | * Get the default options of all components of the library |
||
| 191 | * |
||
| 192 | * @return array<string,string|bool|integer> |
||
| 193 | */ |
||
| 194 | private static function getDefaultOptions(): array |
||
| 195 | { |
||
| 196 | // The default configuration settings. |
||
| 197 | return [ |
||
| 198 | 'core.version' => self::VERSION, |
||
| 199 | 'core.language' => 'en', |
||
| 200 | 'core.encoding' => 'utf-8', |
||
| 201 | 'core.decode_utf8' => false, |
||
| 202 | 'core.prefix.function' => 'jaxon_', |
||
| 203 | 'core.prefix.class' => 'Jaxon', |
||
| 204 | // 'core.request.uri' => '', |
||
| 205 | 'core.request.mode' => 'asynchronous', |
||
| 206 | 'core.request.method' => 'POST', // W3C: Method is case sensitive |
||
| 207 | 'core.response.send' => true, |
||
| 208 | 'core.response.merge.ap' => true, |
||
| 209 | 'core.response.merge.js' => true, |
||
| 210 | 'core.debug.on' => false, |
||
| 211 | 'core.debug.verbose' => false, |
||
| 212 | 'core.process.exit' => true, |
||
| 213 | 'core.process.clean' => false, |
||
| 214 | 'core.process.timeout' => 6000, |
||
| 215 | 'core.error.handle' => false, |
||
| 216 | 'core.error.log_file' => '', |
||
| 217 | 'core.jquery.no_conflict' => false, |
||
| 218 | 'core.upload.enabled' => true, |
||
| 219 | 'js.lib.output_id' => 0, |
||
| 220 | 'js.lib.queue_size' => 0, |
||
| 221 | 'js.lib.load_timeout' => 2000, |
||
| 222 | 'js.lib.show_status' => false, |
||
| 223 | 'js.lib.show_cursor' => true, |
||
| 224 | 'js.app.dir' => '', |
||
| 225 | 'js.app.minify' => true, |
||
| 226 | 'js.app.options' => '', |
||
| 227 | ]; |
||
| 228 | } |
||
| 229 | |||
| 230 | /** |
||
| 231 | * Get the DI container |
||
| 232 | * |
||
| 233 | * @return Container |
||
| 234 | */ |
||
| 235 | public function di(): ?Container |
||
| 236 | { |
||
| 237 | return self::$xContainer; |
||
| 238 | } |
||
| 239 | |||
| 240 | /** |
||
| 241 | * Get the logger |
||
| 242 | * |
||
| 243 | * @return LoggerInterface |
||
| 244 | */ |
||
| 245 | public function logger(): LoggerInterface |
||
| 246 | { |
||
| 247 | return $this->logger; |
||
| 248 | } |
||
| 249 | |||
| 250 | /** |
||
| 251 | * Get the library config |
||
| 252 | * |
||
| 253 | * @return Config |
||
| 254 | */ |
||
| 255 | public function config(): Config |
||
| 256 | { |
||
| 257 | return $this->xConfig; |
||
| 258 | } |
||
| 259 | |||
| 260 | /** |
||
| 261 | * Read a config file |
||
| 262 | * |
||
| 263 | * @param string $sConfigFile |
||
| 264 | * |
||
| 265 | * @return array |
||
| 266 | * @throws SetupException |
||
| 267 | */ |
||
| 268 | public function readConfig(string $sConfigFile): array |
||
| 269 | { |
||
| 270 | try |
||
| 271 | { |
||
| 272 | return $this->xConfigReader->read($sConfigFile); |
||
| 273 | } |
||
| 274 | catch(YamlExtension $e) |
||
| 275 | { |
||
| 276 | $sMessage = $this->xTranslator->trans('errors.yaml.install'); |
||
| 277 | throw new SetupException($sMessage); |
||
| 278 | } |
||
| 279 | catch(FileExtension $e) |
||
| 280 | { |
||
| 281 | $sMessage = $this->xTranslator->trans('errors.file.extension', ['path' => $sConfigFile]); |
||
| 282 | throw new SetupException($sMessage); |
||
| 283 | } |
||
| 284 | catch(FileAccess $e) |
||
| 285 | { |
||
| 286 | $sMessage = $this->xTranslator->trans('errors.file.access', ['path' => $sConfigFile]); |
||
| 287 | throw new SetupException($sMessage); |
||
| 288 | } |
||
| 289 | catch(FileContent $e) |
||
| 290 | { |
||
| 291 | $sMessage = $this->xTranslator->trans('errors.file.content', ['path' => $sConfigFile]); |
||
| 292 | throw new SetupException($sMessage); |
||
| 293 | } |
||
| 294 | } |
||
| 295 | |||
| 296 | /** |
||
| 297 | * Load a config file |
||
| 298 | * |
||
| 299 | * @param string $sConfigFile |
||
| 300 | * @param string $sConfigSection |
||
| 301 | * |
||
| 302 | * @return void |
||
| 303 | * @throws SetupException |
||
| 304 | */ |
||
| 305 | public function loadConfig(string $sConfigFile, string $sConfigSection = '') |
||
| 306 | { |
||
| 307 | $aConfigOptions = $this->readConfig($sConfigFile); |
||
| 308 | try |
||
| 309 | { |
||
| 310 | // Set up the lib config options. |
||
| 311 | $this->xConfig->setOptions($aConfigOptions, $sConfigSection); |
||
| 312 | } |
||
| 313 | catch(DataDepth $e) |
||
| 314 | { |
||
| 315 | $sMessage = $this->xTranslator->trans('errors.data.depth', ['key' => $e->sPrefix, 'depth' => $e->nDepth]); |
||
| 316 | throw new SetupException($sMessage); |
||
| 317 | } |
||
| 318 | } |
||
| 319 | |||
| 320 | /** |
||
| 321 | * Set the value of a config option |
||
| 322 | * |
||
| 323 | * @param string $sName The option name |
||
| 324 | * @param mixed $sValue The option value |
||
| 325 | * |
||
| 326 | * @return void |
||
| 327 | */ |
||
| 328 | public function setOption(string $sName, $sValue) |
||
| 329 | { |
||
| 330 | $this->xConfig->setOption($sName, $sValue); |
||
| 331 | } |
||
| 332 | |||
| 333 | /** |
||
| 334 | * Get the value of a config option |
||
| 335 | * |
||
| 336 | * @param string $sName The option name |
||
| 337 | * @param mixed|null $xDefault The default value, to be returned if the option is not defined |
||
| 338 | * |
||
| 339 | * @return mixed The option value, or null if the option is unknown |
||
| 340 | */ |
||
| 341 | public function getOption(string $sName, $xDefault = null) |
||
| 342 | { |
||
| 343 | return $this->xConfig->getOption($sName, $xDefault); |
||
| 344 | } |
||
| 345 | |||
| 346 | /** |
||
| 347 | * Check the presence of a config option |
||
| 348 | * |
||
| 349 | * @param string $sName The option name |
||
| 350 | * |
||
| 351 | * @return bool True if the option exists, and false if not |
||
| 352 | */ |
||
| 353 | public function hasOption(string $sName): bool |
||
| 354 | { |
||
| 355 | return $this->xConfig->hasOption($sName); |
||
| 356 | } |
||
| 357 | |||
| 358 | /** |
||
| 359 | * Create a new the config set |
||
| 360 | * |
||
| 361 | * @return Config The config manager |
||
| 362 | * @throws SetupException |
||
| 363 | */ |
||
| 364 | public function newConfig(): Config |
||
| 365 | { |
||
| 366 | return $this->di()->newConfig(); |
||
| 367 | } |
||
| 368 | |||
| 369 | /** |
||
| 370 | * Get the configured character encoding |
||
| 371 | * |
||
| 372 | * @return string |
||
| 373 | */ |
||
| 374 | public function getCharacterEncoding(): string |
||
| 375 | { |
||
| 376 | return trim($this->xConfig->getOption('core.encoding')); |
||
| 377 | } |
||
| 378 | |||
| 379 | /** |
||
| 380 | * Get a translated string |
||
| 381 | * |
||
| 382 | * @param string $sText The key of the translated string |
||
| 383 | * @param array $aPlaceHolders The placeholders of the translated string |
||
| 384 | * @param string $sLanguage The language of the translated string |
||
| 385 | * |
||
| 386 | * @return string |
||
| 387 | */ |
||
| 388 | public function trans(string $sText, array $aPlaceHolders = [], string $sLanguage = ''): string |
||
| 389 | { |
||
| 390 | return $this->xTranslator->trans($sText, $aPlaceHolders, $sLanguage); |
||
| 391 | } |
||
| 392 | |||
| 393 | /** |
||
| 394 | * Get the Global Response object |
||
| 395 | * |
||
| 396 | * @return AbstractResponse |
||
| 397 | */ |
||
| 398 | public function getResponse(): AbstractResponse |
||
| 399 | { |
||
| 400 | if(($xResponse = $this->xResponseManager->getResponse())) |
||
| 401 | { |
||
| 402 | return $xResponse; |
||
| 403 | } |
||
| 404 | return $this->di()->getResponse(); |
||
| 405 | } |
||
| 406 | |||
| 407 | /** |
||
| 408 | * Create a new Jaxon response object |
||
| 409 | * |
||
| 410 | * @return Response |
||
| 411 | */ |
||
| 412 | public function newResponse(): Response |
||
| 413 | { |
||
| 414 | return $this->di()->newResponse(); |
||
| 415 | } |
||
| 416 | |||
| 417 | /** |
||
| 418 | * Register a plugin |
||
| 419 | * |
||
| 420 | * Below is a table for priorities and their description: |
||
| 421 | * - 0 to 999: Plugins that are part of or extensions to the jaxon core |
||
| 422 | * - 1000 to 8999: User created plugins, typically, these plugins don't care about order |
||
| 423 | * - 9000 to 9999: Plugins that generally need to be last or near the end of the plugin list |
||
| 424 | * |
||
| 425 | * @param string $sClassName The plugin class |
||
| 426 | * @param string $sPluginName The plugin name |
||
| 427 | * @param integer $nPriority The plugin priority, used to order the plugins |
||
| 428 | * |
||
| 429 | * @return void |
||
| 430 | * @throws SetupException |
||
| 431 | */ |
||
| 432 | public function registerPlugin(string $sClassName, string $sPluginName, int $nPriority = 1000) |
||
| 433 | { |
||
| 434 | $this->xPluginManager->registerPlugin($sClassName, $sPluginName, $nPriority); |
||
| 435 | } |
||
| 436 | |||
| 437 | /** |
||
| 438 | * Register a package |
||
| 439 | * |
||
| 440 | * @param string $sClassName The package class |
||
| 441 | * @param array $aOptions The package options |
||
| 442 | * |
||
| 443 | * @return void |
||
| 444 | * @throws SetupException |
||
| 445 | */ |
||
| 446 | public function registerPackage(string $sClassName, array $aOptions = []) |
||
| 447 | { |
||
| 448 | $this->xPluginManager->registerPackage($sClassName, $aOptions); |
||
| 449 | } |
||
| 450 | |||
| 451 | /** |
||
| 452 | * Register request handlers, including functions, callable classes and directories. |
||
| 453 | * |
||
| 454 | * @param string $sType The type of request handler being registered |
||
| 455 | * Options include: |
||
| 456 | * - Jaxon::CALLABLE_FUNCTION: a function declared at global scope |
||
| 457 | * - Jaxon::CALLABLE_CLASS: a class who's methods are to be registered |
||
| 458 | * - Jaxon::CALLABLE_DIR: a directory containing classes to be registered |
||
| 459 | * @param string $sName |
||
| 460 | * When registering a function, this is the name of the function |
||
| 461 | * When registering a callable class, this is the class name |
||
| 462 | * When registering a callable directory, this is the full path to the directory |
||
| 463 | * @param array|string $xOptions The related options |
||
| 464 | * |
||
| 465 | * @return void |
||
| 466 | * @throws SetupException |
||
| 467 | */ |
||
| 468 | public function register(string $sType, string $sName, $xOptions = []) |
||
| 469 | { |
||
| 470 | $this->xPluginManager->registerCallable($sType, $sName, $xOptions); |
||
| 471 | } |
||
| 472 | |||
| 473 | /** |
||
| 474 | * Get an instance of a registered class |
||
| 475 | * |
||
| 476 | * @param string $sClassName The class name |
||
| 477 | * |
||
| 478 | * @return null|object |
||
| 479 | */ |
||
| 480 | public function instance(string $sClassName) |
||
| 481 | { |
||
| 482 | $xCallable = $this->xCallableRegistry->getCallableObject($sClassName); |
||
| 483 | return ($xCallable) ? $xCallable->getRegisteredObject() : null; |
||
| 484 | } |
||
| 485 | |||
| 486 | /** |
||
| 487 | * Get the factory |
||
| 488 | * |
||
| 489 | * @return Factory |
||
| 490 | */ |
||
| 491 | public function factory(): Factory |
||
| 492 | { |
||
| 493 | return $this->di()->g(Factory::class); |
||
| 494 | } |
||
| 495 | |||
| 496 | /** |
||
| 497 | * Get a request to a registered class |
||
| 498 | * |
||
| 499 | * @param string $sClassName The class name |
||
| 500 | * |
||
| 501 | * @return RequestFactory|null |
||
| 502 | */ |
||
| 503 | public function request(string $sClassName): ?RequestFactory |
||
| 504 | { |
||
| 505 | return $this->factory()->request($sClassName); |
||
| 506 | } |
||
| 507 | |||
| 508 | /** |
||
| 509 | * Returns the Jaxon Javascript header and wrapper code to be printed into the page |
||
| 510 | * |
||
| 511 | * The javascript code returned by this function is dependent on the plugins |
||
| 512 | * that are included and the functions and classes that are registered. |
||
| 513 | * |
||
| 514 | * @param bool $bIncludeJs Also get the JS files |
||
| 515 | * @param bool $bIncludeCss Also get the CSS files |
||
| 516 | * |
||
| 517 | * @return string |
||
| 518 | * @throws UriException |
||
| 519 | */ |
||
| 520 | public function getScript(bool $bIncludeJs = false, bool $bIncludeCss = false): string |
||
| 521 | { |
||
| 522 | return $this->xCodeGenerator->getScript($bIncludeJs, $bIncludeCss); |
||
| 523 | } |
||
| 524 | |||
| 525 | /** |
||
| 526 | * Print the jaxon Javascript header and wrapper code into your page |
||
| 527 | * |
||
| 528 | * The javascript code returned by this function is dependent on the plugins |
||
| 529 | * that are included and the functions and classes that are registered. |
||
| 530 | * |
||
| 531 | * @param bool $bIncludeJs Also print the JS files |
||
| 532 | * @param bool $bIncludeCss Also print the CSS files |
||
| 533 | * |
||
| 534 | * @return void |
||
| 535 | * @throws UriException |
||
| 536 | */ |
||
| 537 | public function printScript(bool $bIncludeJs = false, bool $bIncludeCss = false) |
||
| 538 | { |
||
| 539 | print $this->getScript($bIncludeJs, $bIncludeCss); |
||
| 540 | } |
||
| 541 | |||
| 542 | /** |
||
| 543 | * Return the javascript header code and file includes |
||
| 544 | * |
||
| 545 | * @return string |
||
| 546 | */ |
||
| 547 | public function getJs(): string |
||
| 548 | { |
||
| 549 | return $this->xCodeGenerator->getJs(); |
||
| 550 | } |
||
| 551 | |||
| 552 | /** |
||
| 553 | * Return the CSS header code and file includes |
||
| 554 | * |
||
| 555 | * @return string |
||
| 556 | */ |
||
| 557 | public function getCss(): string |
||
| 558 | { |
||
| 559 | return $this->xCodeGenerator->getCss(); |
||
| 560 | } |
||
| 561 | |||
| 562 | /** |
||
| 563 | * Determine if a call is a jaxon request or a page load request |
||
| 564 | * |
||
| 565 | * @return bool |
||
| 566 | */ |
||
| 567 | public function canProcessRequest(): bool |
||
| 568 | { |
||
| 569 | return $this->xRequestHandler->canProcessRequest(); |
||
| 570 | } |
||
| 571 | |||
| 572 | /** |
||
| 573 | * If this is a jaxon request, call the requested PHP function, build the response and send it back to the browser |
||
| 574 | * |
||
| 575 | * This is the main server side engine for Jaxon. |
||
| 576 | * It handles all the incoming requests, including the firing of events and handling of the response. |
||
| 577 | * If your RequestURI is the same as your web page, then this function should be called before ANY |
||
| 578 | * headers or HTML is output from your script. |
||
| 579 | * |
||
| 580 | * This function may exit after the request is processed, if the 'core.process.exit' option is set to true. |
||
| 581 | * |
||
| 582 | * @return void |
||
| 583 | * |
||
| 584 | * @throws RequestException |
||
| 585 | * @see <Jaxon\Jaxon->canProcessRequest> |
||
| 586 | */ |
||
| 587 | public function processRequest() |
||
| 588 | { |
||
| 589 | // Check to see if headers have already been sent out, in which case we can't do our job |
||
| 590 | if(headers_sent($filename, $linenumber)) |
||
| 591 | { |
||
| 592 | echo $this->xTranslator->trans('errors.output.already-sent', [ |
||
| 593 | 'location' => $filename . ':' . $linenumber |
||
| 594 | ]), "\n", $this->xTranslator->trans('errors.output.advice'); |
||
| 595 | exit(); |
||
| 596 | } |
||
| 597 | |||
| 598 | $this->xRequestHandler->processRequest(); |
||
| 599 | |||
| 600 | if(($this->xConfig->getOption('core.response.send'))) |
||
| 601 | { |
||
| 602 | $this->xResponseManager->sendOutput(); |
||
| 603 | if(($this->xConfig->getOption('core.process.exit'))) |
||
| 604 | { |
||
| 605 | exit(); |
||
| 606 | } |
||
| 607 | } |
||
| 608 | } |
||
| 609 | |||
| 610 | /** |
||
| 611 | * Get a registered response plugin |
||
| 612 | * |
||
| 613 | * @param string $sName The name of the plugin |
||
| 614 | * |
||
| 615 | * @return ResponsePlugin |
||
| 616 | */ |
||
| 617 | public function plugin(string $sName): ResponsePlugin |
||
| 620 | } |
||
| 621 | |||
| 622 | /** |
||
| 623 | * Get a package instance |
||
| 624 | * |
||
| 625 | * @param string $sClassName The package class name |
||
| 626 | * |
||
| 627 | * @return Package |
||
| 628 | */ |
||
| 629 | public function package(string $sClassName): Package |
||
| 630 | { |
||
| 631 | return $this->xPluginManager->getPackage($sClassName); |
||
| 632 | } |
||
| 633 | |||
| 634 | /** |
||
| 635 | * Get the upload plugin |
||
| 636 | * |
||
| 637 | * @return UploadPlugin|null |
||
| 638 | */ |
||
| 639 | public function upload(): ?UploadPlugin |
||
| 640 | { |
||
| 641 | return $this->di()->getUploadPlugin(); |
||
| 642 | } |
||
| 643 | |||
| 644 | /** |
||
| 645 | * Get the request callback manager |
||
| 646 | * |
||
| 647 | * @return Callback |
||
| 648 | */ |
||
| 649 | public function callback(): Callback |
||
| 650 | { |
||
| 651 | return $this->xRequestHandler->getCallbackManager(); |
||
| 652 | } |
||
| 653 | |||
| 654 | /** |
||
| 655 | * Get the dialog wrapper |
||
| 656 | * |
||
| 657 | * @return Dialog |
||
| 658 | */ |
||
| 659 | public function dialog(): Dialog |
||
| 660 | { |
||
| 661 | return $this->di()->getDialog(); |
||
| 662 | } |
||
| 663 | |||
| 664 | /** |
||
| 665 | * Get the template engine |
||
| 666 | * |
||
| 667 | * @return TemplateEngine |
||
| 668 | */ |
||
| 669 | public function template(): TemplateEngine |
||
| 670 | { |
||
| 671 | return $this->di()->getTemplateEngine(); |
||
| 672 | } |
||
| 673 | |||
| 674 | /** |
||
| 675 | * Get the App instance |
||
| 676 | * |
||
| 677 | * @return App |
||
| 678 | */ |
||
| 679 | public function app(): App |
||
| 680 | { |
||
| 681 | return $this->di()->getApp(); |
||
| 682 | } |
||
| 683 | |||
| 684 | /** |
||
| 685 | * Get the view renderer |
||
| 686 | * |
||
| 687 | * @return Renderer |
||
| 688 | */ |
||
| 689 | public function view(): Renderer |
||
| 690 | { |
||
| 691 | return $this->di()->getViewRenderer(); |
||
| 692 | } |
||
| 693 | |||
| 694 | /** |
||
| 695 | * Get the session manager |
||
| 696 | * |
||
| 697 | * @return Session |
||
| 698 | */ |
||
| 699 | public function session(): Session |
||
| 702 | } |
||
| 703 | } |
||
| 704 |