Documentation

How to use

1. Create class Span

class Span extends \Mesour\UI\Control
{


}

2. Add some prototype method

/**
* @return \Mesour\Components\Utils\Html
*/
public function getControlPrototype()
{
    return !$this->wrapper ? ($this->wrapper = \Mesour\Components\Utils\Html::el('span')) : $this->wrapper;
}

3. Add some configuration method

public function setText($text)
{
    $this->text = $text;
    return $this;
}

4. Add create method

public function create()
{
    $wrapper = $this->getControlPrototype();
    $wrapper->setText($this->text);
    return $wrapper;
}

5. Complete component Span source code

class Span extends \Mesour\UI\Control
{

    /**
     * @var \Mesour\Components\Utils\Html
     */
    private $wrapper;

    private $text = 'Default content';

    /**
    * @return \Mesour\Components\Utils\Html
    */
    public function getControlPrototype()
    {
        return !$this->wrapper ? ($this->wrapper = \Mesour\Components\Utils\Html::el('span')) : $this->wrapper;
    }

    public function setText($text)
    {
        $this->text = $text;
        return $this;
    }

    public function render()
    {
        $wrapper = $this->getControlPrototype();
        $wrapper->setText($this->text);
        echo $wrapper;
    }

}

Usage

$span = new \Span();

$span->setText('Test span text.');

$span->render();

Result

<span>Test span text.</span>