Blade   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A render() 0 16 2
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017-2025
6
 * @package Base
7
 * @subpackage View
8
 */
9
10
11
namespace Aimeos\Base\View\Engine;
12
13
14
/**
15
 * Blade view engine implementation
16
 *
17
 * @package Base
18
 * @subpackage View
19
 */
20
class Blade implements Iface
21
{
22
	private \Illuminate\View\Factory $factory;
23
24
25
	/**
26
	 * Initializes the view object
27
	 *
28
	 * @param \Illuminate\View\Factory $factory Laravel view factory
29
	 */
30
	public function __construct( \Illuminate\View\Factory $factory )
31
	{
32
		$this->factory = $factory;
33
	}
34
35
36
	/**
37
	 * Renders the output based on the given template file name and the key/value pairs
38
	 *
39
	 * @param \Aimeos\Base\View\Iface $view View object
40
	 * @param string $filename File name of the view template
41
	 * @param array $values Associative list of key/value pairs
42
	 * @return string Output generated by the template
43
	 * @throws \Aimeos\Base\View\Exception If the template isn't found
44
	 */
45
	public function render( \Aimeos\Base\View\Iface $view, string $filename, array $values ) : string
46
	{
47
		$factory = $this->factory;
48
		$lv = $factory->file( $filename, $values );
49
50
		$fcn = function() use ( $factory, $view )
51
		{
52
			foreach( $factory->getSections() as $name => $section ) {
53
				$view->block()->set( $name, $section );
54
			}
55
		};
56
57
		$contents = $lv->render( $fcn );
58
		$this->factory->flushSections();
59
60
		return $contents;
61
	}
62
}
63