Completed
Branch master (e379bd)
by Pierre-Henry
33:06
created

Smarty_Internal_Compile_Block_Parent::compile()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 10
nc 4
nop 3
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/*
3
 * This file is part of Smarty.
4
 *
5
 * (c) 2015 Uwe Tews
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
/**
12
 * Smarty Internal Plugin Compile Block Parent Class
13
 *
14
 * @author Uwe Tews <[email protected]>
15
 */
16
class Smarty_Internal_Compile_Block_Parent extends Smarty_Internal_Compile_Shared_Inheritance
17
{
18
19
    /**
20
     * Attribute definition: Overwrites base class.
21
     *
22
     * @var array
23
     * @see Smarty_Internal_CompileBase
24
     */
25
    public $optional_attributes = array('name');
26
27
    /**
28
     * Attribute definition: Overwrites base class.
29
     *
30
     * @var array
31
     * @see Smarty_Internal_CompileBase
32
     */
33
    public $shorttag_order = array('name');
34
35
    /**
36
     * Attribute definition: Overwrites base class.
37
     *
38
     * @var array
39
     * @see Smarty_Internal_CompileBase
40
     */
41
    public $option_flags = array();
42
43
    /**
44
     * Saved compiler object
45
     *
46
     * @var Smarty_Internal_TemplateCompilerBase
47
     */
48
    public $compiler = null;
49
50
    /**
51
     * Compiles code for the {block_parent} tag
52
     *
53
     * @param  array                                 $args      array with attributes from parser
54
     * @param  \Smarty_Internal_TemplateCompilerBase $compiler  compiler object
55
     * @param  array                                 $parameter array with compilation parameter
56
     *
57
     * @return bool true
58
     */
59
    public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
0 ignored issues
show
Unused Code introduced by
The parameter $parameter 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...
60
    {
61
        // check and get attributes
62
        $_attr = $this->getAttributes($compiler, $args);
63
        if (!isset($compiler->_cache[ 'blockNesting' ])) {
64
            $compiler->trigger_template_error(' tag {$smarty.block.parent} used outside {block} tags ',
65
                                              $compiler->parser->lex->taglineno);
66
        }
67
        $compiler->suppressNocacheProcessing = true;
68
        $compiler->has_code = true;
69
        $output = "<?php \n\$_smarty_tpl->inheritance->callParent(\$_smarty_tpl, \$this" .
70
                  (isset($_attr[ 'name' ]) ? ", {$_attr[ 'name' ]}" : '') . ");\n?>\n";
71
        return $output;
72
    }
73
}