summaryrefslogtreecommitdiff
path: root/app/Core/Helper.php
blob: 53084a7e81dfbc16fc14bd5d3eea681df2036c74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php

namespace Core;

/**
 * Helper base class
 *
 * @package core
 * @author  Frederic Guillot
 *
 * @property \Helper\App        $app
 * @property \Helper\Asset      $asset
 * @property \Helper\Datetime   $datetime
 * @property \Helper\File       $file
 * @property \Helper\Form       $form
 * @property \Helper\Subtask    $subtask
 * @property \Helper\Task       $task
 * @property \Helper\Text       $text
 * @property \Helper\Url        $url
 * @property \Helper\User       $user
 */
class Helper extends Base
{
    /**
     * Helper instances
     *
     * @static
     * @access private
     * @var array
     */
    private static $helpers = array();

    /**
     * Load automatically helpers
     *
     * @access public
     * @param  string    $name    Helper name
     * @return mixed
     */
    public function __get($name)
    {
        if (! isset(self::$helpers[$name])) {
            $class = '\Helper\\'.ucfirst($name);
            self::$helpers[$name] = new $class($this->container);
        }

        return self::$helpers[$name];
    }

    /**
     * HTML escaping
     *
     * @param  string   $value    Value to escape
     * @return string
     */
    public function e($value)
    {
        return htmlspecialchars($value, ENT_QUOTES, 'UTF-8', false);
    }
}