1 | <?php |
||
9 | abstract class ScriptAbstractCreator |
||
10 | { |
||
11 | /** |
||
12 | * Относительный путь к директории скриптов |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | public $path = '/js/'; |
||
17 | |||
18 | /** |
||
19 | * Допустимые имена скриптов |
||
20 | * |
||
21 | * @var array of strings |
||
22 | */ |
||
23 | public static $scripts = array('packed.js', 'compiled.js', 'vendor.js', 'common.js'); |
||
24 | |||
25 | /** |
||
26 | * Список имя скриптов |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $scriptList; |
||
31 | |||
32 | |||
33 | /** |
||
34 | * @throws CException |
||
35 | * |
||
36 | * @return array |
||
37 | */ |
||
38 | 11 | final public function getScriptList() |
|
39 | { |
||
40 | 11 | if( !is_array($this->scriptList) ) |
|
41 | 11 | throw new CException("Свойство scriptList дожно быть массивом"); |
|
42 | |||
43 | 11 | if( empty($this->scriptList) ) |
|
44 | 11 | throw new CException("Имя список не может быть пустым"); |
|
45 | |||
46 | 11 | foreach($this->scriptList as $scriptName) |
|
47 | 11 | if( !in_array($scriptName, static::$scripts) ) |
|
48 | 11 | throw new CException("Неверное имя или путь скрипта ".$scriptName); |
|
49 | |||
50 | 11 | return $this->getScriptPath(); |
|
51 | } |
||
52 | |||
53 | 8 | public function addScript($script) |
|
54 | { |
||
55 | 8 | $this->scriptList[] = $script; |
|
56 | 8 | } |
|
57 | |||
58 | /** |
||
59 | * Обновление файла крипта |
||
60 | * Скрипт обновляется только в случае, |
||
61 | * когда обновилась контрольная сумма файлов, |
||
62 | * либо не существует сам файл скриптов |
||
63 | */ |
||
64 | 8 | public function update() |
|
74 | |||
75 | /** |
||
76 | * Возвращает полный путь к файлу скриптов |
||
77 | * |
||
78 | * @return array |
||
79 | */ |
||
80 | public function getScriptPath() |
||
86 | |||
87 | 10 | public function scripsExists() |
|
91 | |||
92 | /** |
||
93 | * Возвращает допустимые полные пути к скриптам |
||
94 | * |
||
95 | * @return array |
||
96 | */ |
||
97 | protected function scriptsPath() |
||
108 | |||
109 | 10 | protected function scriptListExist(array $scriptList) |
|
121 | |||
122 | abstract public function create(); |
||
123 | |||
124 | abstract protected function delete(); |
||
125 | } |
||
126 |
This check looks for access to properties that are not accessible from the current context.
If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.