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

namespace Redstart\Templating\Escape;

/**
 * Escape Component
 * 
 * @package Redstart    
 * @subpackage Redstart_Templating_Escape
 *
 * @author Hyyan Abo Fakher
 * @since Redstart 1.0
 * @version 1.0
 */
class EscapeComponent {

    private $escapehandler;

    /**
     * Constrcut new escape component
     * @param \Redstart\Templating\Escape\EscapeHandlerInterface $handler
     */
    public function __construct(EscapeHandlerInterface $handler = null) {
        $this->setEscapeHandler(
                $handler === null ? new EscapeHandler() : $handler
        );
    }

    /**
     * Set Escape Handler
     * @param \Redstart\Templating\Escape\EscapeHandlerInterface $handler
     * @return \Redstart\Templating\Escape\EscapeComponent
     */
    public function setEscapeHandler(EscapeHandlerInterface $handler) {
        $this->escapehandler = $handler;
        return $this;
    }

    /**
     * Get escape handler
     * @return \Redstart\Templating\Escape\EscapeHandlerInterface
     */
    public function getEscapeHandler() {
        return $this->escapehandler;
    }

    /**
     * Set escape list
     * @param \Redstart\Templating\Escape\EscapeListInterface $list
     * @return \Redstart\Templating\Escape\EscapeComponent
     */
    public function setEscapeList(EscapeListInterface $list) {
        $this->getEscapeHandler()->setEscapeList($list);
        return $this;
    }

    /**
     * Get escape list
     * @return \Redstart\Templating\Escape\EscapeListInterface 
     */
    public function getEscapeList() {
        return $this->getEscapeHandler()->getEscapeList();
    }

    /**
     * Add new escape listener
     * @param mixed $listener
     * @return \Redstart\Templating\Escape\EscapeComponent
     */
    public function addEscape($listener) {
        $this->getEscapeList()->addEscape($listener);
        return $this;
    }

    /**
     * Add Array of escape listeners
     * @param array $listeners
     * @return \Redstart\Templating\Escape\EscapeComponent
     */
    public function setEscape(array $listeners) {
        $this->getEscapeList()->setEscape($listeners);
        return $this;
    }

    /**
     * Applies escaping to a value.
     * 
     * @param string $value the value to apply escaping to it
     * @param array $listeners array of listeners to overide predefined escaping
     *                         listeners
     * 
     * @return string escaped value
     */
    public function escape($value, array $listeners = array()) {
        return $this->getEscapeHandler()->escape($value, $listeners);
    }

    /**
     * Prints a value after escaping it
     * 
     * @see Template::escape()
     * 
     * @param string $value the value to apply escaping to it
     * @param array $listeners array of listeners to overide predefined escaping
     *                         listeners
     * @return  \Redstart\Templating\Escape\EscapeComponent
     */
    public function eprint($value, array $listeners = array()) {
        echo $this->escape($value, $listeners);
        return $this;
    }

}

Return current item: Redstart Templating