Passed
Push — master ( 6c3354...3ac5ed )
by Thierry
02:07
created

Container::getTranslator()   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
     * Save a closure in the container
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
     * Save a value in the container
314
     *
315
     * @param string                $sKey               The key
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 16 found
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter name; 15 found
Loading history...
316
     * @param mixed                 $xValue             The value
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 13 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 17 found
Loading history...
317
     *
318
     * @return void
319
     */
320
    public function val($sKey, $xValue)
321
    {
322
        $this->libContainer[$sKey] = $xValue;
323
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
324
325
    /**
326
     * Set an alias in the container
327
     *
328
     * @param string                $sAlias             The alias name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 13 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 16 found
Loading history...
329
     * @param string                $sClass             The class name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 13 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 16 found
Loading history...
330
     *
331
     * @return void
332
     */
333
    public function alias($sAlias, $sClass)
334
    {
335
        $this->libContainer[$sAlias] = function($c) use ($sClass) {
336
            return $c[$sClass];
337
        };
338
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
339
340
    /**
341
     * Create an instance of a class, getting the contructor parameters from the DI container
342
     *
343
     * @param string|ReflectionClass    $xClass         The class name or the reflection class
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 9 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 4 found
Loading history...
344
     *
345
     * @return mixed
346
     */
347
    public function make($xClass)
348
    {
349
        if(is_string($xClass))
350
        {
351
            // Create the reflection class instance
352
            $xClass = new ReflectionClass($xClass);
353
        }
354
        if(!($xClass instanceof ReflectionClass))
0 ignored issues
show
introduced by
$xClass is always a sub-type of ReflectionClass.
Loading history...
355
        {
356
            return null;
357
        }
358
        // Use the Reflection class to get the parameters of the constructor
359
        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...
360
        {
361
            return $xClass->newInstance();
362
        }
363
        $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...
364
        $parameterInstances = [];
365
        foreach($parameters as $parameter)
366
        {
367
            // Get the parameter instance from the DI
368
            $parameterInstances[] = $this->get($parameter->getClass()->getName());
369
        }
370
        return $xClass->newInstanceArgs($parameterInstances);
371
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
372
373
    /**
374
     * Create an instance of a class by automatically fetching the dependencies from the constructor.
375
     *
376
     * @param string                $sClass             The class name
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 13 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 16 found
Loading history...
377
     *
378
     * @return void
379
     */
380
    public function auto($sClass)
381
    {
382
        $this->libContainer[$sClass] = function($c) use ($sClass) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

382
        $this->libContainer[$sClass] = function(/** @scrutinizer ignore-unused */ $c) use ($sClass) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
383
            return $this->make($sClass);
384
        };
385
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
386
387
    /**
388
     * Get the plugin manager
389
     *
390
     * @return PluginManager
391
     */
392
    public function getPluginManager()
393
    {
394
        return $this->libContainer[PluginManager::class];
395
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
396
397
    /**
398
     * Get the request handler
399
     *
400
     * @return RequestHandler
401
     */
402
    public function getRequestHandler()
403
    {
404
        return $this->libContainer[RequestHandler::class];
405
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
406
407
    /**
408
     * Get the request factory
409
     *
410
     * @return RequestFactory
411
     */
412
    public function getRequestFactory()
413
    {
414
        return $this->libContainer[RequestFactory::class];
415
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
416
417
    /**
418
     * Get the parameter factory
419
     *
420
     * @return ParameterFactory
421
     */
422
    public function getParameterFactory()
423
    {
424
        return $this->libContainer[ParameterFactory::class];
425
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
426
427
    /**
428
     * Get the response manager
429
     *
430
     * @return ResponseManager
431
     */
432
    public function getResponseManager()
433
    {
434
        return $this->libContainer[ResponseManager::class];
435
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
436
437
    /**
438
     * Get the code generator
439
     *
440
     * @return CodeGenerator
441
     */
442
    public function getCodeGenerator()
443
    {
444
        return $this->libContainer[CodeGenerator::class];
445
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
446
447
    /**
448
     * Get the callable registry
449
     *
450
     * @return CallableRegistry
451
     */
452
    public function getCallableRegistry()
453
    {
454
        return $this->libContainer[CallableRegistry::class];
455
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
456
457
    /**
458
     * Get the config manager
459
     *
460
     * @return Config
461
     */
462
    public function getConfig()
463
    {
464
        return $this->libContainer[Config::class];
465
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
466
467
    /**
468
     * Create a new the config manager
469
     *
470
     * @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...
471
     * @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...
472
     *
473
     * @return Config            The config manager
474
     */
475
    public function newConfig(array $aOptions = [], $sKeys = '')
476
    {
477
        return new Config($aOptions, $sKeys);
478
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
479
480
    /**
481
     * Get the dialog wrapper
482
     *
483
     * @return Dialog
484
     */
485
    public function getDialog()
486
    {
487
        return $this->libContainer[Dialog::class];
488
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
489
490
    /**
491
     * Get the minifier
492
     *
493
     * @return Minifier
494
     */
495
    public function getMinifier()
496
    {
497
        return $this->libContainer[Minifier::class];
498
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
499
500
    /**
501
     * Get the translator
502
     *
503
     * @return Translator
504
     */
505
    public function getTranslator()
506
    {
507
        return $this->libContainer[Translator::class];
508
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
509
510
    /**
511
     * Get the template engine
512
     *
513
     * @return TemplateEngine
514
     */
515
    public function getTemplateEngine()
516
    {
517
        return $this->libContainer[TemplateEngine::class];
518
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
519
520
    /**
521
     * Get the validator
522
     *
523
     * @return Validator
524
     */
525
    public function getValidator()
526
    {
527
        return $this->libContainer[Validator::class];
528
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
529
530
    /**
531
     * Get the paginator
532
     *
533
     * @return Paginator
534
     */
535
    public function getPaginator()
536
    {
537
        return $this->libContainer[Paginator::class];
538
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
539
540
    /**
541
     * Get the event dispatcher
542
     *
543
     * @return EventDispatcher
544
     */
545
    public function getEventDispatcher()
546
    {
547
        return $this->libContainer[EventDispatcher::class];
548
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
549
550
    /**
551
     * Get the global Response object
552
     *
553
     * @return Response
554
     */
555
    public function getResponse()
556
    {
557
        return $this->libContainer[Response::class];
558
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
559
560
    /**
561
     * Create a new Jaxon response object
562
     *
563
     * @return Response
564
     */
565
    public function newResponse()
566
    {
567
        return new Response();
568
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
569
570
    /**
571
     * Get the App instance
572
     *
573
     * @return App
574
     */
575
    public function getApp()
576
    {
577
        return $this->libContainer[App::class];
578
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
579
580
    /**
581
     * Get the App bootstrap
582
     *
583
     * @return Bootstrap
584
     */
585
    public function getBootstrap()
586
    {
587
        return $this->libContainer[Bootstrap::class];
588
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
589
590
    /**
591
     * Get the view manager
592
     *
593
     * @return ViewManager
594
     */
595
    public function getViewManager()
596
    {
597
        return $this->libContainer[ViewManager::class];
598
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
599
600
    /**
601
     * Get the view facade
602
     *
603
     * @return ViewRenderer
604
     */
605
    public function getViewRenderer()
606
    {
607
        return $this->libContainer[ViewRenderer::class];
608
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
609
610
    /**
611
     * Get the session manager
612
     *
613
     * @return SessionContract
614
     */
615
    public function getSessionManager()
616
    {
617
        return $this->libContainer[SessionContract::class];
618
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
619
620
    /**
621
     * Set the session manager
622
     *
623
     * @param Closure      $xClosure      A closure to create the session manager instance
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 6 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 6 found
Loading history...
624
     *
625
     * @return void
626
     */
627
    public function setSessionManager(Closure $xClosure)
628
    {
629
        $this->libContainer[SessionContract::class] = $xClosure;
630
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
631
632
    /**
633
     * Set the callable class request factory
634
     *
635
     * @param string            $sClassName         The callable class name
0 ignored issues
show
Coding Style introduced by
Expected 6 spaces after parameter name; 9 found
Loading history...
Coding Style introduced by
Expected 9 spaces after parameter type; 12 found
Loading history...
636
     * @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...
637
     *
638
     * @return void
639
     */
640
    public function setCallableClassRequestFactory($sClassName, CallableObject $xCallableObject)
641
    {
642
        $this->libContainer[$sClassName . '_RequestFactory'] = function() use ($xCallableObject) {
643
            return new CallableClassRequestFactory($xCallableObject);
644
        };
645
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
646
647
    /**
648
     * Get the callable class request factory
649
     *
650
     * @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...
651
     *
652
     * @return CallableClassRequestFactory
653
     */
654
    public function getCallableClassRequestFactory($sClassName)
655
    {
656
        return $this->libContainer[$sClassName . '_RequestFactory'];
657
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
658
}
659