Skip to content

Commit e36c624

Browse files
committed
Updated dependency injection and exception.
Signed-off-by: Joshua Parker <[email protected]>
1 parent 53b7997 commit e36c624

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

View/FenomView.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
use Fenom;
88
use Fenom\Error\CompileException;
99
use Fenom\Provider;
10+
use Qubus\Config\ConfigContainer;
11+
use Qubus\Exception\Data\TypeException;
12+
use Qubus\Exception\Exception;
1013
use Qubus\View\Renderer;
1114

1215
use function Codefy\Framework\Helpers\config;
@@ -15,13 +18,17 @@ final class FenomView implements Renderer
1518
{
1619
private Fenom $fenom;
1720

18-
public function __construct()
21+
/**
22+
* @throws TypeException
23+
* @throws Exception
24+
*/
25+
public function __construct(protected ConfigContainer $configContainer)
1926
{
2027
$this->fenom = (new Fenom(
21-
provider: new Provider(template_dir: config(key: 'view.path'))
28+
provider: new Provider(template_dir: $this->configContainer->getConfigKey(key: 'view.path'))
2229
))->setCompileDir(
23-
dir: config(key: 'view.cache')
24-
)->setOptions(options: config(key: 'view.options'));
30+
dir: $this->configContainer->getConfigKey(key: 'view.cache')
31+
)->setOptions(options: $this->configContainer->getConfigKey(key: 'view.options'));
2532
}
2633

2734
/**

View/FoilView.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
namespace Codefy\Framework\View;
66

77
use Foil\Engine;
8+
use Qubus\Config\ConfigContainer;
9+
use Qubus\Exception\Data\TypeException;
10+
use Qubus\Exception\Exception;
811
use Qubus\View\Renderer;
912

1013
use function Codefy\Framework\Helpers\config;
@@ -14,9 +17,13 @@ final class FoilView implements Renderer
1417
{
1518
private Engine $engine;
1619

17-
public function __construct()
20+
/**
21+
* @throws TypeException
22+
* @throws Exception
23+
*/
24+
public function __construct(protected ConfigContainer $configContainer)
1825
{
19-
$this->engine = engine(config(key: 'view.options'));
26+
$this->engine = engine($this->configContainer->getConfigKey(key: 'view.options'));
2027
}
2128

2229
public function render(array|string $template, array $data = []): string|array

0 commit comments

Comments
 (0)