Location: PHPKode > scripts > Redstart Templating > Redstart-Templating-master/Redstart/Templating/PHP/BlockPlugin.php
<?php

namespace Redstart\Templating\PHP;

use Redstart\Templating\Plugin\Plugin;

/**
 * Block Plugin
 *
 * @package Redstart    
 * @subpackage Redstart_Templating_Php
 *
 * @author Hyyan Abo Fakher
 * @since Redstart 1.0
 * @version 1.0
 */
class BlockPlugin extends Plugin {

    protected $compiler;

    /**
     * Constrcut new php block plugin
     * @param \Redstart\Templating\PHP\PHPCompiler $compiler
     */
    public function __construct(PHPCompiler $compiler) {
        parent::__construct($compiler->getTemplate());
        $this->compiler = $compiler;
    }

    /**
     * Extend other php template
     * @param string $file file name
     * @param string $external true to stop looking in the template path list
     *                         or false to use the template path list
     * @return \Redstart\Templating\PHP\BlockPlugin
     */
    public function decorate($file, $external = false) {
        $this->compiler->decorate($file, $external);
        return $this;
    }

    /**
     * Call the parent block of the current open block
     * @throws \LogicException if there is no open slot or if the slot has 
     * no parent
     * @return \Redstart\Templating\PHP\BlockPlugin
     */
    public function super() {
        $this->compiler->super();
        return $this;
    }

    /**
     * Start new php block
     * @param string $name block name
     * @throws \LogicException if the block name is already started or declared
     * @return \Redstart\Templating\PHP\BlockPlugin
     */
    public function open($name) {
        $this->compiler->block($name);
        return $this;
    }

    /**
     * End last open block
     * @throws \LogicException if there is no open block
     * @return \Redstart\Templating\PHP\BlockPlugin
     */
    public function close() {
        $this->compiler->endBlock();
        return $this;
    }

    /**
     * Check if block exist
     * @param string $name block name
     * @return boolean true if block exists false otherwise
     */
    public function hasBlock($name) {
        return $this->compiler->hasBlock($name);
    }

    /**
     * Create an empty block or empty block
     * @param string $name block name
     * @return type
     */
    public function emptyBlock($name) {
        return $this->open($name)->close();
    }

    /**
     * Get plugin name
     * @return string
     */
    final public function getName() {
        return 'block';
    }

}

Return current item: Redstart Templating