Hooks::on_alter_engine_collection()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Patron package.
5
 *
6
 * (c) Olivier Laviale <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Patron\RenderSupport;
13
14
use ICanBoogie\Render;
15
use ICanBoogie\Render\EngineCollection;
16
17
class Hooks
18
{
19
	/*
20
	 * Events
21
	 */
22
23
	/**
24
	 * Add the _Patron_ engine for ".patron" templates.
25
	 *
26
	 * @param EngineCollection\AlterEvent $event
27
	 * @param EngineCollection $target
28
	 */
29
	static public function on_alter_engine_collection(EngineCollection\AlterEvent $event, EngineCollection $target)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

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

Loading history...
30
	{
31
		$target['.patron'] = __NAMESPACE__ . '\PatronEngine';
32
	}
33
34
	/*
35
	 * Markups
36
	 */
37
38
	static public function markup_render(array $args, $engine, $template)
39
	{
40
		$thisArg = $args['select'];
41
		unset($args['select']);
42
43
		if (is_array($thisArg))
44
		{
45
			$thisArg = new \ArrayObject($thisArg);
46
		}
47
48
		$renderer = Render\get_renderer();
49
50
		$html = $renderer->render($thisArg, $args + [
51
52
			'locals' => $engine->context->to_array()
53
54
		]);
55
56
		return $template ? $engine($template, $html) : $html;
57
	}
58
}
59