1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace League\Plates\Extension\LayoutSections; |
4
|
|
|
|
5
|
|
|
use League\Plates; |
6
|
|
|
use League\Plates\Extension\RenderContext; |
7
|
|
|
|
8
|
|
|
final class LayoutSectionsExtension implements Plates\Extension |
9
|
|
|
{ |
10
|
|
|
public function register(Plates\Engine $plates) { |
11
|
|
|
$c = $plates->getContainer(); |
12
|
|
|
|
13
|
|
|
$c->merge('config', ['default_layout_path' => null]); |
14
|
|
|
$c->wrap('compose', function($compose, $c) { |
|
|
|
|
15
|
|
|
return Plates\Util\compose($compose, sectionsCompose()); |
16
|
|
|
}); |
17
|
|
|
$c->wrap('renderTemplate.factories', function($factories, $c) { |
18
|
|
|
$default_layout_path = $c->get('config')['default_layout_path']; |
19
|
|
|
if ($default_layout_path) { |
20
|
|
|
$factories[] = DefaultLayoutRenderTemplate::factory($default_layout_path); |
21
|
|
|
} |
22
|
|
|
$factories[] = LayoutRenderTemplate::factory(); |
23
|
|
|
return $factories; |
24
|
|
|
}); |
25
|
|
|
$c->wrap('renderContext.func.funcs', function($funcs, $c) { |
|
|
|
|
26
|
|
|
$template_args = RenderContext\assertTemplateArgsFunc(); |
27
|
|
|
$one_arg = RenderContext\assertArgsFunc(1); |
28
|
|
|
|
29
|
|
|
return array_merge($funcs, [ |
30
|
|
|
'layout' => [$template_args, layoutFunc()], |
31
|
|
|
'section' => [$one_arg, sectionFunc()], |
32
|
|
|
'start' => [$one_arg, startFunc()], |
33
|
|
|
'push' => [$one_arg, startFunc(START_APPEND)], |
34
|
|
|
'unshift' => [$one_arg, startFunc(START_PREPEND)], |
35
|
|
|
]); |
36
|
|
|
}); |
37
|
|
|
} |
38
|
|
|
} |
39
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.