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

namespace Redstart\Templating\Compiler;

use Redstart\Templating\Template;

/**
 * Abstract Template Compiler
 *
 * @package Redstart    
 * @subpackage Redstart_Templating_Complier
 *
 * @author Hyyan Abo Fakher
 * @since Redstart 1.0
 * @version 1.0
 */
abstract class Compiler implements CompilerInterface {

    /**
     * Template 
     * @var \Redstart\Templating\TemplateInterface 
     */
    protected $template;

    /**
     * Constrcut New Comiler
     * @param \Redstart\Templating\Template $template
     */
    public function __construct(Template $template) {
        $this->template = $template;
    }

    /**
     * Get Comiler's template
     * @return \Redstart\Templating\Template
     */
    public function getTemplate() {
        return $this->template;
    }

    /**
     * Compile the given file 
     * @param string $file file path
     * @return string
     * @throws \RuntimeException if the file is not supported
     */
    final public function compile($file) {
        if (!$this->isSupported($file)) {
            throw new \RuntimeException(
            sprintf("Template Compiler Does Not Support The Given File Type Of (%s)"
                    , $file)
            );
        }
        return $this->doCompile($file);
    }

    /**
     * Compile the given file 
     * @param string $file file path
     * @return string
     */
    abstract protected function doCompile($file);

    /**
     * Called by the template after the template is included in the
     * <tt>fetch</tt> scope
     * @param string $content the content of the included template
     * @return string the new content
     */
    public function fetched($content) {
        return $content;
    }

    /**
     * Called by the template when the compiler is attached 
     */
    public function install() {}

    /**
     * Called by the template before the new complier is set
     */
    public function uninstall() {}

    /**
     * Called by the template after the template file is fetched and the after
     * the compiler's <tt>fetched()</tt> method is called
     */
    public function finalize() {}

}

Return current item: Redstart Templating