Passed
Push — master ( 68b778...1b1614 )
by Thierry
07:15 queued 04:29
created

Container::getConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * Container.php - Jaxon data container
5
 *
6
 * Provide container service for Jaxon utils class instances.
7
 *
8
 * @package jaxon-core
0 ignored issues
show
Coding Style introduced by
Package name "jaxon-core" is not valid; consider "Jaxoncore" instead
Loading history...
9
 * @author Thierry Feuzeu <[email protected]>
10
 * @copyright 2016 Thierry Feuzeu <[email protected]>
11
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
12
 * @link https://github.com/jaxon-php/jaxon-core
13
 */
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...
14
15
namespace Jaxon\Utils\DI;
16
17
use Jaxon\Response\Response;
18
use Jaxon\Request\Support\CallableRegistry;
19
use Jaxon\Request\Support\CallableRepository;
20
use Jaxon\Request\Plugin\CallableClass;
21
use Jaxon\Request\Plugin\CallableDir;
22
use Jaxon\Request\Plugin\CallableFunction;
23
use Jaxon\Request\Plugin\FileUpload;
24
use Jaxon\Request\Support\FileUpload as FileUploadSupport;
25
use Jaxon\Request\Handler\Handler as RequestHandler;
26
use Jaxon\Request\Factory\RequestFactory;
27
use Jaxon\Request\Factory\ParameterFactory;
28
use Jaxon\Request\Factory\CallableClass\Request as CallableClassRequestFactory;
29
use Jaxon\Request\Factory\CallableClass\Paginator as CallableClassPaginatorFactory;
30
use Jaxon\Request\Support\CallableObject;
31
use Jaxon\Response\Manager as ResponseManager;
32
use Jaxon\Response\Plugin\JQuery as JQueryPlugin;
33
use Jaxon\Plugin\Manager as PluginManager;
34
use Jaxon\Plugin\Code\Generator as CodeGenerator;
35
use Jaxon\Contracts\Session as SessionContract;
36
37
use Jaxon\App\App;
38
use Jaxon\App\Bootstrap;
39
40
use Jaxon\Utils\Config\Config;
41
use Jaxon\Utils\Config\Reader as ConfigReader;
42
use Jaxon\Utils\View\Manager as ViewManager;
43
use Jaxon\Utils\View\Renderer as ViewRenderer;
44
use Jaxon\Utils\Dialogs\Dialog;
45
use Jaxon\Utils\Template\Minifier;
46
use Jaxon\Utils\Template\Engine as TemplateEngine;
47
use Jaxon\Utils\Template\View as TemplateView;
48
use Jaxon\Utils\Pagination\Paginator;
49
use Jaxon\Utils\Pagination\Renderer as PaginationRenderer;
50
use Jaxon\Utils\Validation\Validator;
51
use Jaxon\Utils\Translation\Translator;
52
use Jaxon\Utils\Session\Manager as SessionManager;
53
use Jaxon\Utils\Http\URI;
54
55
use Pimple\Container as PimpleContainer;
56
use Psr\Container\ContainerInterface;
57
use Lemon\Event\EventDispatcher;
58
use Closure;
59
use ReflectionClass;
60
61
class Container
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class Container
Loading history...
62
{
63
    /**
64
     * The Dependency Injection Container
65
     *
66
     * @var PimpleContainer
67
     */
68
    private $libContainer = null;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
69
70
    /**
71
     * The Dependency Injection Container
72
     *
73
     * @var ContainerInterface
74
     */
75
    private $appContainer = null;
76
77
    /**
78
     * The class constructor
79
     *
80
     * @param array     $aOptions       The default options
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 5 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 7 found
Loading history...
81
     */
82
    public function __construct(array $aOptions)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
83
    {
84
        $this->libContainer = new PimpleContainer();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 19 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...
85
        $this->libContainer[Container::class] = $this;
0 ignored issues
show
Coding Style introduced by
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
86
87
        $sTranslationDir = realpath(__DIR__ . '/../../../translations');
88
        $sTemplateDir = realpath(__DIR__ . '/../../../templates');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 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...
89
        $this->init($sTranslationDir, $sTemplateDir);
90
        $this->getConfig()->setOptions($aOptions);
91
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
92
93
    /**
94
     * Get the container provided by the integrated framework
95
     *
96
     * @return ContainerInterface
97
     */
98
    public function getAppContainer()
99
    {
100
        return $this->appContainer;
101
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
102
103
    /**
104
     * Set the container provided by the integrated framework
105
     *
106
     * @param ContainerInterface  $container     The container implementation
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 5 found
Loading history...
107
     *
108
     * @return void
109
     */
110
    public function setAppContainer(ContainerInterface $container)
111
    {
112
        $this->appContainer = $container;
113
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
114
115
    /**
116
     * Set the parameters and create the objects in the dependency injection container
117
     *
118
     * @param string        $sTranslationDir     The translation directory
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 5 found
Loading history...
119
     * @param string        $sTemplateDir        The template directory
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter name; 8 found
Loading history...
120
     *
121
     * @return void
122
     */
123
    private function init($sTranslationDir, $sTemplateDir)
124
    {
125
        /*
126
         * Parameters
127
         */
0 ignored issues
show
Coding Style introduced by
Empty line required after block comment
Loading history...
128
        // Translation directory
129
        $this->libContainer['jaxon.core.translation_dir'] = $sTranslationDir;
130
        // Template directory
131
        $this->libContainer['jaxon.core.template_dir'] = $sTemplateDir;
132
133
        /*
134
         * Core library objects
135
         */
0 ignored issues
show
Coding Style introduced by
Empty line required after block comment
Loading history...
136
        // Global Response
137
        $this->libContainer[Response::class] = function() {
138
            return new Response();
139
        };
140
        // Dialog
141
        $this->libContainer[Dialog::class] = function() {
142
            return new Dialog();
143
        };
144
        // Jaxon App
145
        $this->libContainer[App::class] = function() {
146
            return new App();
147
        };
148
        // Jaxon App bootstrap
149
        $this->libContainer[Bootstrap::class] = function() {
150
            return new Bootstrap();
151
        };
152
153
        /*
154
         * Plugins
155
         */
0 ignored issues
show
Coding Style introduced by
Empty line required after block comment
Loading history...
156
        // Callable objects repository
157
        $this->libContainer[CallableRepository::class] = function() {
158
            return new CallableRepository();
159
        };
160
        // Callable objects registry
161
        $this->libContainer[CallableRegistry::class] = function($c) {
162
            return new CallableRegistry($c[CallableRepository::class]);
163
        };
164
        // Callable class plugin
165
        $this->libContainer[CallableClass::class] = function($c) {
166
            return new CallableClass($c[CallableRegistry::class], $c[CallableRepository::class]);
167
        };
168
        // Callable dir plugin
169
        $this->libContainer[CallableDir::class] = function($c) {
170
            return new CallableDir($c[CallableRegistry::class]);
171
        };
172
        // Callable function plugin
173
        $this->libContainer[CallableFunction::class] = function() {
174
            return new CallableFunction();
175
        };
176
        // File upload support
177
        $this->libContainer[FileUploadSupport::class] = function() {
178
            return new FileUploadSupport();
179
        };
180
        // File upload plugin
181
        $this->libContainer[FileUpload::class] = function($c) {
182
            return new FileUpload($c[FileUploadSupport::class]);
183
        };
184
        // JQuery response plugin
185
        $this->libContainer[JQueryPlugin::class] = function() {
186
            return new JQueryPlugin();
187
        };
188
189
        /*
190
         * Managers
191
         */
0 ignored issues
show
Coding Style introduced by
Empty line required after block comment
Loading history...
192
        // Plugin Manager
193
        $this->libContainer[PluginManager::class] = function($c) {
194
            return new PluginManager($c[CodeGenerator::class]);
195
        };
196
        // Request Handler
197
        $this->libContainer[RequestHandler::class] = function($c) {
198
            return new RequestHandler($c[PluginManager::class], $c[ResponseManager::class], $c[FileUpload::class]);
199
        };
200
        // Request Factory
201
        $this->libContainer[RequestFactory::class] = function($c) {
202
            return new RequestFactory($c[CallableRegistry::class]);
203
        };
204
        // Parameter Factory
205
        $this->libContainer[ParameterFactory::class] = function() {
206
            return new ParameterFactory();
207
        };
208
        // Response Manager
209
        $this->libContainer[ResponseManager::class] = function() {
210
            return new ResponseManager();
211
        };
212
        // Code Generator
213
        $this->libContainer[CodeGenerator::class] = function($c) {
214
            return new CodeGenerator($c[TemplateEngine::class]);
215
        };
216
        // View Manager
217
        $this->libContainer[ViewManager::class] = function() {
218
            $xViewManager = new ViewManager();
219
            // Add the default view renderer
220
            $xViewManager->addRenderer('jaxon', function($di) {
221
                return new TemplateView($di->get(TemplateEngine::class));
222
            });
223
            // By default, render pagination templates with Jaxon.
224
            $xViewManager->addNamespace('pagination', '', '.php', 'jaxon');
225
            return $xViewManager;
226
        };
227
        // View Renderer
228
        $this->libContainer[ViewRenderer::class] = function($c) {
229
            return new ViewRenderer($c[ViewManager::class]);
230
        };
231
        // Set the default session manager
232
        $this->libContainer[SessionContract::class] = function() {
233
            return new SessionManager();
234
        };
235
236
        /*
237
         * Config
238
         */
0 ignored issues
show
Coding Style introduced by
Empty line required after block comment
Loading history...
239
        $this->libContainer[Config::class] = function() {
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...
240
            return new Config();
241
        };
242
        $this->libContainer[ConfigReader::class] = function() {
243
            return new ConfigReader();
244
        };
245
246
        /*
247
         * Services
248
         */
0 ignored issues
show
Coding Style introduced by
Empty line required after block comment
Loading history...
249
        // Minifier
250
        $this->libContainer[Minifier::class] = function() {
251
            return new Minifier();
252
        };
253
        // Translator
254
        $this->libContainer[Translator::class] = function($c) {
255
            return new Translator($c['jaxon.core.translation_dir'], $c[Config::class]);
256
        };
257
        // Template engine
258
        $this->libContainer[TemplateEngine::class] = function($c) {
259
            return new TemplateEngine($c['jaxon.core.template_dir']);
260
        };
261
        // Validator
262
        $this->libContainer[Validator::class] = function($c) {
263
            return new Validator($c[Translator::class], $c[Config::class]);
264
        };
265
        // Pagination Paginator
266
        $this->libContainer[Paginator::class] = function($c) {
267
            return new Paginator($c[PaginationRenderer::class]);
268
        };
269
        // Pagination Renderer
270
        $this->libContainer[PaginationRenderer::class] = function($c) {
271
            return new PaginationRenderer($c[ViewRenderer::class]);
272
        };
273
        // Event Dispatcher
274
        $this->libContainer[EventDispatcher::class] = function() {
275
            return new EventDispatcher();
276
        };
277
        // URI decoder
278
        $this->libContainer[URI::class] = function() {
279
            return new URI();
280
        };
281
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
282
283
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $sClass should have a doc-comment as per coding-style.
Loading history...
284
     * Get a class instance
285
     *
286
     * @return object        The class instance
287
     */
288
    public function get($sClass)
289
    {
290
        if($this->appContainer != null && $this->appContainer->has($sClass))
291
        {
292
            return $this->appContainer->get($sClass);
293
        }
294
        return $this->libContainer[$sClass];
295
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
296
297
    /**
298
     * Set a DI closure
299
     *
300
     * @param string                $sClass             The full class name
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 16 found
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter name; 13 found
Loading history...
301
     * @param Closure               $xClosure           The closure
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 15 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 11 found
Loading history...
302
     *
303
     * @return void
304
     */
305
    public function set($sClass, Closure $xClosure)
306
    {
307
        $this->libContainer[$sClass] = function() use($xClosure) {
308
            return call_user_func($xClosure, $this);
309
        };
310
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
311
312
    /**
313
     * Set an alias
314
     *
315
     * @param string                $sClass             The class name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 16 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 13 found
Loading history...
316
     * @param string                $sAlias             The alias name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 16 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 13 found
Loading history...
317
     *
318
     * @return void
319
     */
320
    public function alias($sClass, $sAlias)
321
    {
322
        $this->libContainer[$sClass] = function($c) use ($sAlias) {
323
            return $c[$sAlias];
324
        };
325
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
326
327
    /**
328
     * Create an instance of a class, getting the contructor parameters from the DI container
329
     *
330
     * @param string|ReflectionClass    $xClass         The class name or the reflection class
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 4 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 9 found
Loading history...
331
     *
332
     * @return null|object
333
     */
334
    public function make($xClass)
335
    {
336
        if(is_string($xClass))
337
        {
338
            // Create the reflection class instance
339
            $xClass = new ReflectionClass($xClass);
340
        }
341
        if(!($xClass instanceof ReflectionClass))
0 ignored issues
show
introduced by
$xClass is always a sub-type of ReflectionClass.
Loading history...
342
        {
343
            return null;
344
        }
345
        // Use the Reflection class to get the parameters of the constructor
346
        if(($constructor = $xClass->getConstructor()) == null)
0 ignored issues
show
Coding Style introduced by
Variable assignment found within a condition. Did you mean to do a comparison ?
Loading history...
347
        {
348
            return $xClass->newInstance();
349
        }
350
        $parameters = $constructor->getParameters();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 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...
351
        $parameterInstances = [];
352
        foreach($parameters as $parameter)
353
        {
354
            // Get the parameter instance from the DI
355
            $parameterInstances[] = $this->get($parameter->getClass()->getName());
356
        }
357
        return $xClass->newInstanceArgs($parameterInstances);
358
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
359
360
    /**
361
     * Get the plugin manager
362
     *
363
     * @return PluginManager
364
     */
365
    public function getPluginManager()
366
    {
367
        return $this->libContainer[PluginManager::class];
368
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
369
370
    /**
371
     * Get the request handler
372
     *
373
     * @return RequestHandler
374
     */
375
    public function getRequestHandler()
376
    {
377
        return $this->libContainer[RequestHandler::class];
378
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
379
380
    /**
381
     * Get the request factory
382
     *
383
     * @return RequestFactory
384
     */
385
    public function getRequestFactory()
386
    {
387
        return $this->libContainer[RequestFactory::class];
388
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
389
390
    /**
391
     * Get the parameter factory
392
     *
393
     * @return ParameterFactory
394
     */
395
    public function getParameterFactory()
396
    {
397
        return $this->libContainer[ParameterFactory::class];
398
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
399
400
    /**
401
     * Get the response manager
402
     *
403
     * @return ResponseManager
404
     */
405
    public function getResponseManager()
406
    {
407
        return $this->libContainer[ResponseManager::class];
408
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
409
410
    /**
411
     * Get the code generator
412
     *
413
     * @return CodeGenerator
414
     */
415
    public function getCodeGenerator()
416
    {
417
        return $this->libContainer[CodeGenerator::class];
418
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
419
420
    /**
421
     * Get the callable registry
422
     *
423
     * @return CallableRegistry
424
     */
425
    public function getCallableRegistry()
426
    {
427
        return $this->libContainer[CallableRegistry::class];
428
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
429
430
    /**
431
     * Get the config manager
432
     *
433
     * @return Config
434
     */
435
    public function getConfig()
436
    {
437
        return $this->libContainer[Config::class];
438
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
439
440
    /**
441
     * Create a new the config manager
442
     *
443
     * @param array             $aOptions           The options array
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 13 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 11 found
Loading history...
444
     * @param string            $sKeys              The keys of the options in the array
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 12 found
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter name; 14 found
Loading history...
445
     *
446
     * @return Config            The config manager
447
     */
448
    public function newConfig(array $aOptions = [], $sKeys = '')
449
    {
450
        return new Config($aOptions, $sKeys);
451
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
452
453
    /**
454
     * Get the dialog wrapper
455
     *
456
     * @return Dialog
457
     */
458
    public function getDialog()
459
    {
460
        return $this->libContainer[Dialog::class];
461
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
462
463
    /**
464
     * Get the minifier
465
     *
466
     * @return Minifier
467
     */
468
    public function getMinifier()
469
    {
470
        return $this->libContainer[Minifier::class];
471
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
472
473
    /**
474
     * Get the translator
475
     *
476
     * @return Translator
477
     */
478
    public function getTranslator()
479
    {
480
        return $this->libContainer[Translator::class];
481
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
482
483
    /**
484
     * Get the template engine
485
     *
486
     * @return TemplateEngine
487
     */
488
    public function getTemplateEngine()
489
    {
490
        return $this->libContainer[TemplateEngine::class];
491
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
492
493
    /**
494
     * Get the validator
495
     *
496
     * @return Validator
497
     */
498
    public function getValidator()
499
    {
500
        return $this->libContainer[Validator::class];
501
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
502
503
    /**
504
     * Get the paginator
505
     *
506
     * @return Paginator
507
     */
508
    public function getPaginator()
509
    {
510
        return $this->libContainer[Paginator::class];
511
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
512
513
    /**
514
     * Get the event dispatcher
515
     *
516
     * @return EventDispatcher
517
     */
518
    public function getEventDispatcher()
519
    {
520
        return $this->libContainer[EventDispatcher::class];
521
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
522
523
    /**
524
     * Get the global Response object
525
     *
526
     * @return Response
527
     */
528
    public function getResponse()
529
    {
530
        return $this->libContainer[Response::class];
531
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
532
533
    /**
534
     * Create a new Jaxon response object
535
     *
536
     * @return Response
537
     */
538
    public function newResponse()
539
    {
540
        return new Response();
541
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
542
543
    /**
544
     * Get the App instance
545
     *
546
     * @return App
547
     */
548
    public function getApp()
549
    {
550
        return $this->libContainer[App::class];
551
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
552
553
    /**
554
     * Get the App bootstrap
555
     *
556
     * @return Bootstrap
557
     */
558
    public function getBootstrap()
559
    {
560
        return $this->libContainer[Bootstrap::class];
561
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
562
563
    /**
564
     * Get the view manager
565
     *
566
     * @return ViewManager
567
     */
568
    public function getViewManager()
569
    {
570
        return $this->libContainer[ViewManager::class];
571
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
572
573
    /**
574
     * Get the view facade
575
     *
576
     * @return ViewRenderer
577
     */
578
    public function getViewRenderer()
579
    {
580
        return $this->libContainer[ViewRenderer::class];
581
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
582
583
    /**
584
     * Get the session manager
585
     *
586
     * @return SessionContract
587
     */
588
    public function getSessionManager()
589
    {
590
        return $this->libContainer[SessionContract::class];
591
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
592
593
    /**
594
     * Set the session manager
595
     *
596
     * @param Closure      $xClosure      A closure to create the session manager instance
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 6 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 6 found
Loading history...
597
     *
598
     * @return void
599
     */
600
    public function setSessionManager(Closure $xClosure)
601
    {
602
        $this->libContainer[SessionContract::class] = $xClosure;
603
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
604
605
    /**
606
     * Set the callable class request factory
607
     *
608
     * @param string            $sClassName         The callable class name
0 ignored issues
show
Coding Style introduced by
Expected 9 spaces after parameter type; 12 found
Loading history...
Coding Style introduced by
Expected 6 spaces after parameter name; 9 found
Loading history...
609
     * @param CallableObject    $xCallableObject    The corresponding callable object
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 4 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
610
     *
611
     * @return void
612
     */
613
    public function setCallableClassRequestFactory($sClassName, CallableObject $xCallableObject)
614
    {
615
        $this->libContainer[$sClassName . '_RequestFactory'] = function() use ($xCallableObject) {
616
            return new CallableClassRequestFactory($xCallableObject);
617
        };
618
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
619
620
    /**
621
     * Get the callable class request factory
622
     *
623
     * @param string        $sClassName             The callable class name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 13 found
Loading history...
624
     *
625
     * @return CallableClassRequestFactory
626
     */
627
    public function getCallableClassRequestFactory($sClassName)
628
    {
629
        return $this->libContainer[$sClassName . '_RequestFactory'];
630
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
631
}
632