Passed
Push — master ( b86a9b...818b3e )
by Thierry
02:35
created

Ajax::psr()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * Ajax.php
5
 *
6
 * The Jaxon class uses a modular plug-in system to facilitate the processing
7
 * of special Ajax requests made by a PHP page.
8
 * It generates Javascript that the page must include in order to make requests.
9
 * It handles the output of response commands (see <Jaxon\Response\Response>).
10
 * Many flags and settings can be adjusted to effect the behavior of the Jaxon class
11
 * as well as the client-side javascript.
12
 *
13
 * @package jaxon-core
0 ignored issues
show
Coding Style introduced by
Package name "jaxon-core" is not valid; consider "Jaxoncore" instead
Loading history...
14
 * @author Jared White
0 ignored issues
show
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
15
 * @author J. Max Wilson
0 ignored issues
show
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
16
 * @author Joseph Woolley
0 ignored issues
show
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
17
 * @author Steffen Konerow
0 ignored issues
show
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
18
 * @author Thierry Feuzeu <[email protected]>
19
 * @copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
0 ignored issues
show
Coding Style introduced by
@copyright tag must contain a year and the name of the copyright holder
Loading history...
20
 * @copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White  & J. Max Wilson
0 ignored issues
show
Coding Style introduced by
@copyright tag must contain a year and the name of the copyright holder
Loading history...
21
 * @copyright 2016 Thierry Feuzeu <[email protected]>
22
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
23
 * @link https://github.com/jaxon-php/jaxon-core
24
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
25
26
namespace Jaxon\App;
27
28
use Jaxon\Jaxon;
29
use Jaxon\App\Config\ConfigManager;
30
use Jaxon\App\Dialog\Library\DialogLibraryManager;
31
use Jaxon\App\I18n\Translator;
32
use Jaxon\App\Session\SessionInterface;
33
use Jaxon\App\View\ViewRenderer;
34
use Jaxon\Di\Container;
35
use Jaxon\Exception\RequestException;
36
use Jaxon\Exception\SetupException;
37
use Jaxon\Plugin\Manager\PluginManager;
38
use Jaxon\Plugin\Package;
39
use Jaxon\Plugin\ResponsePlugin;
40
use Jaxon\Request\Call\Paginator;
41
use Jaxon\Request\Factory\Factory;
42
use Jaxon\Request\Factory\Psr\PsrFactory;
43
use Jaxon\Request\Factory\RequestFactory;
44
use Jaxon\Request\Handler\CallbackManager;
45
use Jaxon\Request\Handler\UploadHandler;
46
use Jaxon\Response\Manager\ResponseManager;
47
use Jaxon\Response\Response;
48
use Jaxon\Response\ResponseInterface;
49
use Jaxon\Utils\Http\UriException;
50
use Jaxon\Utils\Template\TemplateEngine;
51
use Psr\Log\LoggerInterface;
52
53
use function gmdate;
54
use function header;
55
use function headers_sent;
56
use function trim;
57
58
class Ajax
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class Ajax
Loading history...
59
{
60
    /**
61
     * @var Ajax
62
     */
63
    private static $xInstance = null;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
64
65
    /**
66
     * @var Container
67
     */
68
    private static $xContainer = null;
69
70
    /**
71
     * @var Bootstrap
72
     */
73
    protected $xBootstrap;
74
75
    /**
76
     * @var Translator
77
     */
78
    protected $xTranslator;
79
80
    /**
81
     * @var ConfigManager
82
     */
83
    protected $xConfigManager;
84
85
    /**
86
     * @var PluginManager
87
     */
88
    protected $xPluginManager;
89
90
    /**
91
     * @var ResponseManager
92
     */
93
    protected $xResponseManager;
94
95
    /**
96
     * @return void
97
     */
98
    private static function initInstance()
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
99
    {
100
        // Set the attributes from the container
101
        self::$xInstance->xBootstrap = self::$xContainer->g(Bootstrap::class);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
102
        self::$xInstance->xTranslator = self::$xContainer->g(Translator::class);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
103
        self::$xInstance->xConfigManager = self::$xContainer->g(ConfigManager::class);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
104
        self::$xInstance->xPluginManager = self::$xContainer->g(PluginManager::class);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
105
        self::$xInstance->xResponseManager = self::$xContainer->g(ResponseManager::class);
106
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
107
108
    /**
109
     * @return Ajax
110
     */
111
    public static function getInstance(): ?Ajax
112
    {
113
        if(self::$xInstance === null)
114
        {
115
            self::$xInstance = new Ajax();
116
            self::$xContainer = new Container(self::$xInstance);
117
            self::initInstance();
118
        }
119
        // Call the on boot callbacks on each call to the jaxon() function.
120
        self::$xInstance->xBootstrap->onBoot();
121
        return self::$xInstance;
122
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
123
124
    /**
125
     * The constructor
126
     */
127
    private function __construct()
128
    {}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
129
130
    /**
131
     * @return string
132
     */
133
    public function getVersion(): string
134
    {
135
        return Jaxon::VERSION;
136
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
137
138
    /**
139
     * @return Container
140
     */
141
    public function di(): ?Container
142
    {
143
        return self::$xContainer;
144
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
145
146
    /**
147
     * @return LoggerInterface
148
     */
149
    public function logger(): LoggerInterface
150
    {
151
        return $this->di()->getLogger();
152
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
153
154
    /**
155
     * Set the value of a config option
156
     *
157
     * @param string $sName    The option name
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
158
     * @param mixed $sValue    The option value
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
159
     *
160
     * @return void
161
     */
162
    public function setOption(string $sName, $sValue)
163
    {
164
        $this->xConfigManager->setOption($sName, $sValue);
165
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
166
167
    /**
168
     * Get the value of a config option
169
     *
170
     * @param string $sName    The option name
0 ignored issues
show
Coding Style introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
171
     * @param mixed|null $xDefault    The default value, to be returned if the option is not defined
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
172
     *
173
     * @return mixed
174
     */
175
    public function getOption(string $sName, $xDefault = null)
176
    {
177
        return $this->xConfigManager->getOption($sName, $xDefault);
178
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
179
180
    /**
181
     * Check the presence of a config option
182
     *
183
     * @param string $sName    The option name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
184
     *
185
     * @return bool
186
     */
187
    public function hasOption(string $sName): bool
188
    {
189
        return $this->xConfigManager->hasOption($sName);
190
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
191
192
    /**
193
     * Read the options from the file, if provided, and return the config
194
     *
195
     * @param string $sConfigFile The full path to the config file
0 ignored issues
show
Coding Style introduced by
Expected 4 spaces after parameter name; 1 found
Loading history...
196
     * @param string $sConfigSection The section of the config file to be loaded
197
     *
198
     * @return ConfigManager
199
     * @throws SetupException
200
     */
201
    public function config(string $sConfigFile = '', string $sConfigSection = ''): ConfigManager
202
    {
203
        if(!empty(($sConfigFile = trim($sConfigFile))))
0 ignored issues
show
Coding Style introduced by
Variable assignment found within a condition. Did you mean to do a comparison ?
Loading history...
204
        {
205
            $this->xConfigManager->load($sConfigFile, trim($sConfigSection));
206
        }
207
        return $this->xConfigManager;
208
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
209
210
    /**
211
     * @return Translator
212
     */
213
    public function translator(): Translator
214
    {
215
        return $this->xTranslator;
216
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
217
218
    /**
219
     * Get the global Response object
220
     *
221
     * @return ResponseInterface
222
     */
223
    public function getResponse(): ResponseInterface
224
    {
225
        return $this->xResponseManager->getResponse();
226
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
227
228
    /**
229
     * Create a new Jaxon response object
230
     *
231
     * @return Response
232
     */
233
    public function newResponse(): Response
234
    {
235
        return $this->di()->newResponse();
236
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
237
238
    /**
239
     * Register a plugin
240
     *
241
     * Below is a table for priorities and their description:
242
     * - 0 to 999: Plugins that are part of or extensions to the jaxon core
243
     * - 1000 to 8999: User created plugins, typically, these plugins don't care about order
244
     * - 9000 to 9999: Plugins that generally need to be last or near the end of the plugin list
245
     *
246
     * @param string $sClassName    The plugin class
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
247
     * @param string $sPluginName    The plugin name
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
248
     * @param integer $nPriority    The plugin priority, used to order the plugins
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
249
     *
250
     * @return void
251
     * @throws SetupException
252
     */
253
    public function registerPlugin(string $sClassName, string $sPluginName, int $nPriority = 1000)
254
    {
255
        $this->xPluginManager->registerPlugin($sClassName, $sPluginName, $nPriority);
256
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
257
258
    /**
259
     * Register a package
260
     *
261
     * @param string $sClassName    The package class
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
262
     * @param array $xPkgOptions    The user provided package options
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
263
     *
264
     * @return void
265
     * @throws SetupException
266
     */
267
    public function registerPackage(string $sClassName, array $xPkgOptions = [])
268
    {
269
        $this->di()->getPackageManager()->registerPackage($sClassName, $xPkgOptions);
270
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
271
272
    /**
273
     * Register request handlers, including functions, callable classes and directories.
274
     *
275
     * @param string $sType    The type of request handler being registered
0 ignored issues
show
Coding Style introduced by
Expected 7 spaces after parameter type; 1 found
Loading history...
276
     *        Options include:
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 25 spaces but found 8
Loading history...
277
     *        - Jaxon::CALLABLE_FUNCTION: a function declared at global scope
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 25 spaces but found 8
Loading history...
278
     *        - Jaxon::CALLABLE_CLASS: a class who's methods are to be registered
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 25 spaces but found 8
Loading history...
279
     *        - Jaxon::CALLABLE_DIR: a directory containing classes to be registered
0 ignored issues
show
Coding Style introduced by
Parameter comment not aligned correctly; expected 25 spaces but found 8
Loading history...
280
     * @param string $sName
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 7 spaces after parameter type; 1 found
Loading history...
281
     *        When registering a function, this is the name of the function
282
     *        When registering a callable class, this is the class name
283
     *        When registering a callable directory, this is the full path to the directory
284
     * @param array|string $xOptions    The related options
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
285
     *
286
     * @return void
287
     * @throws SetupException
288
     */
289
    public function register(string $sType, string $sName, $xOptions = [])
290
    {
291
        $this->xPluginManager->registerCallable($sType, $sName, $xOptions);
292
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
293
294
    /**
295
     * @return Factory
296
     */
297
    public function factory(): Factory
298
    {
299
        return $this->di()->getFactory();
300
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
301
302
    /**
303
     * @return PsrFactory
304
     */
305
    public function psr(): PsrFactory
306
    {
307
        return $this->di()->getPsrFactory();
308
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
309
310
    /**
311
     * @param string $sClassName The class name
312
     *
313
     * @return RequestFactory|null
314
     * @throws SetupException
315
     */
316
    public function request(string $sClassName = ''): ?RequestFactory
317
    {
318
        return $this->factory()->request($sClassName);
319
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
320
321
    /**
322
     * Returns the Jaxon Javascript header and wrapper code to be printed into the page
323
     *
324
     * The javascript code returned by this function is dependent on the plugins
325
     * that are included and the functions and classes that are registered.
326
     *
327
     * @param bool $bIncludeJs    Also get the JS files
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
328
     * @param bool $bIncludeCss    Also get the CSS files
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
329
     *
330
     * @return string
331
     * @throws UriException
332
     */
333
    public function getScript(bool $bIncludeJs = false, bool $bIncludeCss = false): string
334
    {
335
        return $this->di()->getCodeGenerator()->getScript($bIncludeJs, $bIncludeCss);
336
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
337
338
    /**
339
     * Return the javascript header code and file includes
340
     *
341
     * @return string
342
     */
343
    public function getJs(): string
344
    {
345
        return $this->di()->getCodeGenerator()->getJs();
346
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
347
348
    /**
349
     * Return the CSS header code and file includes
350
     *
351
     * @return string
352
     */
353
    public function getCss(): string
354
    {
355
        return $this->di()->getCodeGenerator()->getCss();
356
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
357
358
    /**
359
     * Determine if a call is a jaxon request or a page load request
360
     *
361
     * @return bool
362
     */
363
    public function canProcessRequest(): bool
364
    {
365
        return $this->di()->getRequestHandler()->canProcessRequest();
366
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
367
368
    /**
369
     * If this is a jaxon request, call the requested PHP function, build the response and send it back to the browser
370
     *
371
     * This is the main server side engine for Jaxon.
372
     * It handles all the incoming requests, including the firing of events and handling of the response.
373
     * If your RequestURI is the same as your web page, then this function should be called before ANY
374
     * headers or HTML is output from your script.
375
     *
376
     * This function may exit after the request is processed, if the 'core.process.exit' option is set to true.
377
     *
378
     * @return void
379
     *
380
     * @throws RequestException
381
     * @see <Jaxon\Jaxon->canProcessRequest>
382
     */
383
    public function processRequest()
384
    {
385
        // Check to see if headers have already been sent out, in which case we can't do our job
386
        if(headers_sent($sFilename, $nLineNumber))
387
        {
388
            $sMessage = $this->xTranslator->trans('errors.output.already-sent', [
389
                'location' => $sFilename . ':' . $nLineNumber
390
            ]) . "\n" . $this->xTranslator->trans('errors.output.advice');
391
            throw new RequestException($sMessage);
392
        }
393
394
        $this->di()->getRequestHandler()->processRequest();
395
396
        if($this->xConfigManager->getOption('core.response.send'))
397
        {
398
            $this->sendResponse();
399
        }
400
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
401
402
    /**
403
     * Prints the response to the output stream, thus sending the response to the browser
404
     *
405
     * @return void
406
     */
407
    public function sendResponse()
408
    {
409
        if(empty($sContent = $this->xResponseManager->getOutput()))
0 ignored issues
show
Coding Style introduced by
Variable assignment found within a condition. Did you mean to do a comparison ?
Loading history...
410
        {
411
            return;
412
        }
413
        if($this->di()->getRequest()->getMethod() === 'GET')
414
        {
415
            header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
416
            header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
417
            header("Cache-Control: no-cache, must-revalidate");
418
            header("Pragma: no-cache");
419
        }
420
        header('content-type: ' . $this->xResponseManager->getContentType());
421
        print $sContent;
422
        if($this->xConfigManager->getOption('core.process.exit'))
423
        {
424
            exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
425
        }
426
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
427
428
    /**
429
     * Get a registered response plugin
430
     *
431
     * @param string $sName    The name of the plugin
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
432
     *
433
     * @return ResponsePlugin|null
434
     */
435
    public function plugin(string $sName): ?ResponsePlugin
436
    {
437
        return $this->xPluginManager->getResponsePlugin($sName);
438
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
439
440
    /**
441
     * Get a package instance
442
     *
443
     * @param string $sClassName    The package class name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
444
     *
445
     * @return Package|null
446
     */
447
    public function package(string $sClassName): ?Package
448
    {
449
        return $this->di()->getPackageManager()->getPackage($sClassName);
450
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
451
452
    /**
453
     * @return UploadHandler|null
454
     */
455
    public function upload(): ?UploadHandler
456
    {
457
        return $this->di()->getUploadHandler();
458
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
459
460
    /**
461
     * @return CallbackManager
462
     */
463
    public function callback(): CallbackManager
464
    {
465
        return $this->di()->getCallbackManager();
466
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
467
468
    /**
469
     * @return TemplateEngine
470
     */
471
    public function template(): TemplateEngine
472
    {
473
        return $this->di()->getTemplateEngine();
474
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
475
476
    /**
477
     * @return App
478
     */
479
    public function app(): App
480
    {
481
        return $this->di()->getApp();
482
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
483
484
    /**
485
     * @return ViewRenderer
486
     */
487
    public function view(): ViewRenderer
488
    {
489
        return $this->di()->getViewRenderer();
490
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
491
492
    /**
493
     * @return Paginator
494
     */
495
    public function paginator(): Paginator
496
    {
497
        return $this->di()->getPaginator();
498
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
499
500
    /**
501
     * @return DialogLibraryManager
502
     */
503
    public function dialog(): DialogLibraryManager
504
    {
505
        return $this->di()->getDialogLibraryManager();
506
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
507
508
    /**
509
     * @return SessionInterface|null
510
     */
511
    public function session(): ?SessionInterface
512
    {
513
        return $this->di()->getSessionManager();
514
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
515
516
    /**
517
     * @return void
518
     * @throws SetupException
519
     */
520
    public function reset()
521
    {
522
        self::$xInstance = null;
523
        self::$xContainer = null;
524
        // Need to register the default plugins.
525
        self::getInstance()->di()->getPluginManager()->registerPlugins();
526
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
527
}
528