Completed
Pull Request — master (#104)
by
unknown
07:23
created

TComponentView::getTemplate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 5
c 1
b 1
f 0
rs 9.4286
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
namespace Nayjest\Grids\Components\Base;
3
4
trait TComponentView
5
{
6
    use TRenderable {
7
        TRenderable::getTemplate as private getTemplateInternal;
8
    }
9
10
    protected $render_section;
11
12
    /**
13
     * Returns variables for usage inside view template.
14
     *
15
     * @return array
16
     */
17
    protected function getViewData()
18
    {
19
        return $this->grid->getViewData() + [
0 ignored issues
show
Bug introduced by
The property grid does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
20
            'component' => $this
21
        ];
22
    }
23
24
    /**
25
     * Returns name of view template.
26
     *
27
     * @return string
28
     */
29
    public function getTemplate()
30
    {
31
        $grid_tpl = $this->grid->getConfig()->getTemplate();
32
        return str_replace('*.',"$grid_tpl.", $this->template);
33
    }
34
35
    /**
36
     * Returns name of section in parent component
37
     * where this component must be rendered.
38
     *
39
     * @return string|null
40
     */
41
    public function getRenderSection()
42
    {
43
        return $this->render_section;
44
    }
45
46
    /**
47
     * Sets name of section in parent component
48
     * where this component must be rendered.
49
     *
50
     * @param string|null $sectionName
51
     * @return $this
52
     */
53
    public function setRenderSection($sectionName)
54
    {
55
        $this->render_section = $sectionName;
56
        return $this;
57
    }
58
}
59