forked from noumo/easyii
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAPI.php
45 lines (39 loc) · 1.11 KB
/
API.php
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
<?php
namespace yii\easyii\components;
use Yii;
/**
* Base API component. Used by all modules
* @package yii\easyii\components
*/
class API extends \yii\base\Object
{
/** @var array */
static $classes;
/** @var string module name */
public $module;
public function init()
{
parent::init();
$this->module = Module::getModuleName(self::className());
Module::registerTranslations($this->module);
}
public static function __callStatic($method, $params)
{
$name = static::className();
if (!isset(static::$classes[$name])) {
static::$classes[$name] = new static();
}
return call_user_func_array([static::$classes[$name], 'api_' . $method], $params);
}
/**
* Wrap text with liveEdit tags, which later will fetched by jquery widget
* @param $text
* @param $path
* @param string $tag
* @return string
*/
public static function liveEdit($text, $path, $tag = 'span')
{
return $text ? '<'.$tag.' class="easyiicms-edit" data-edit="'.$path.'">'.$text.'</'.$tag.'>' : '';
}
}