Completed
Push — 183-default-layout-ext ( a97107 )
by
unknown
10:37
created

LayoutSections/LayoutSectionsExtension.php (2 issues)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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) {
0 ignored issues
show
The parameter $c 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...
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) {
0 ignored issues
show
The parameter $c 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...
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