1 <?php
2 /**
3 * WhPlugin class file.
4 * Extends the plugins with common shared methods.
5 *
6 * @author Antonio Ramirez <amigo.cobos@gmail.com>
7 * @copyright Copyright © Antonio Ramirez 2013-
8 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
9 * @package yiiwheels.behaviors
10 */
11 class WhPlugin extends CBehavior
12 {
13 protected $_assetsUrl;
14
15 protected static $_api;
16
17 protected static $_wheels;
18
19 /**
20 * Returns
21 * @param $path
22 * @return mixed
23 */
24 public function getAssetsUrl($path)
25 {
26 if (isset($this->_assetsUrl)) {
27 return $this->_assetsUrl;
28 } else {
29 $forceCopyAssets = $this->getApi()->forceCopyAssets;
30
31 $assetsUrl = Yii::app()->assetManager->publish($path, false, -1, $forceCopyAssets);
32
33 return $this->_assetsUrl = $assetsUrl;
34 }
35 }
36
37 /**
38 * @return TbApi
39 */
40 public function getApi()
41 {
42 if (self::$_api === null) {
43 self::$_api = self::getYiiWheels()->getApi();
44 }
45 return self::$_api;
46 }
47
48 /**
49 * Returns the main component
50 * @return YiiWheels
51 */
52 public function getYiiWheels()
53 {
54 if (self::$_wheels === null) {
55 self::$_wheels = Yii::app()->getComponent('yiiwheels');
56 }
57 return self::$_wheels;
58 }
59 }