1 | <?php |
||||
2 | |||||
3 | namespace Jaxon\Di\Traits; |
||||
4 | |||||
5 | use Jaxon\Utils\Config\ConfigReader; |
||||
6 | use Jaxon\Utils\Http\UriDetector; |
||||
7 | use Jaxon\Utils\Template\TemplateEngine; |
||||
8 | |||||
9 | use function rtrim; |
||||
10 | use function trim; |
||||
11 | |||||
12 | trait UtilTrait |
||||
13 | { |
||||
14 | /** |
||||
15 | * Register the values into the container |
||||
16 | * |
||||
17 | * @return void |
||||
18 | */ |
||||
19 | private function registerUtils() |
||||
20 | { |
||||
21 | // Config reader |
||||
22 | $this->set(ConfigReader::class, function() { |
||||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
23 | return new ConfigReader(); |
||||
24 | }); |
||||
25 | // Template engine |
||||
26 | $this->set(TemplateEngine::class, function($di) { |
||||
27 | $xTemplateEngine = new TemplateEngine(); |
||||
28 | $sTemplateDir = rtrim(trim($di->g('jaxon.core.dir.template')), '/\\'); |
||||
29 | $sPaginationDir = $sTemplateDir . DIRECTORY_SEPARATOR . 'pagination'; |
||||
30 | $xTemplateEngine->addNamespace('jaxon', $sTemplateDir, '.php'); |
||||
31 | $xTemplateEngine->addNamespace('pagination', $sPaginationDir, '.php'); |
||||
32 | $xTemplateEngine->setDefaultNamespace('jaxon'); |
||||
33 | return $xTemplateEngine; |
||||
34 | }); |
||||
35 | // URI detector |
||||
36 | $this->set(UriDetector::class, function() { |
||||
37 | return new UriDetector(); |
||||
38 | }); |
||||
39 | } |
||||
40 | |||||
41 | /** |
||||
42 | * Get the template engine |
||||
43 | * |
||||
44 | * @return TemplateEngine |
||||
45 | */ |
||||
46 | public function getTemplateEngine(): TemplateEngine |
||||
47 | { |
||||
48 | return $this->g(TemplateEngine::class); |
||||
0 ignored issues
–
show
It seems like
g() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
49 | } |
||||
50 | } |
||||
51 |