1: <?php
2: /**
3: * Copyright (c) CMNWorks
4: *
5: * Licensed under The MIT License
6: * For full copyright and license information, please see the LICENSE.txt
7: * Redistributions of files must retain the above copyright notice.
8: *
9: * @copyright Copyright (c) CMNWorks Christopher M. Natan
10: * @author Christopher M. Natan
11: * @link http://cmnworks.com
12: * @since 1.8.8
13: * @license http://www.opensource.org/licenses/mit-license.php MIT License
14: */
15: namespace Cakestrap\View\Helper;
16:
17: use Cake\View\Helper;
18:
19: /**
20: * Bootstrap base class helper.
21: *
22: * Bootstrap class let you encapsulate related helper into a reusable
23: * and testable class.
24: *
25: * @package Cakestrap\View\Helper
26: *
27: * @see AlertHelper()
28: * @see BadgeHelper()
29: * @see ButtonItemsHelper()
30: * @see CallOutHelper()
31: * @see CollapseHelper()
32: * @see DropdownHelper()
33: * @see ListGroupHelper()
34: * @see ModalHelper()
35: * @see PanelHelper()
36: * @see TablesHelper()
37: * @see TabHelper()
38: * @see WellHelper()
39: */
40: class CakestrapHelper extends Helper
41: {
42: /**
43: * PHP reserves all function names starting with __ as magical.
44: *
45: * @param string $method
46: * @param array $args
47: * @return object $this
48: */
49: public function __call($method, $args = [])
50: {
51: $params = array_flip($args);
52: if(isset($params['reset'])) {
53: $this->_View->helpers()->unload('Cakestrap.' . $method);
54: }
55:
56: if(!in_array($method, $this->_View->helpers()->loaded())) {
57: $this->_View->helpers()->load('Cakestrap.' . $method);
58: $this->_View->{$method}->assignTemplate($method);
59: }
60:
61: return $this->_View->{$method};
62: }
63: }