/
RSmartLoad.php
51 lines (45 loc) · 1.27 KB
/
RSmartLoad.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
46
47
48
49
50
51
<?php
namespace istranger\rSmartLoad;
use istranger\rSmartLoad\base;
/**
* Yii2 RSmartLoad class
*
* @author G.Azamat <m@fx4web.com>
* @link http://fx4.ru/
* @link https://github.com/IStranger/yii2-resource-smart-load
* @since 2.0.2
*/
class RSmartLoad extends base\RSmartLoad
{
/**
* @inheritdoc
*/
protected function publishExtensionResources()
{
/** @var View $resourceManager */
$resourceManager = $this->getResourceManager();
// Initialization of extension resources
$assetsExt = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . 'assets';
$assetsPaths = \Yii::$app->getAssetManager()->publish($assetsExt); // [0] - path, [1] - URL
$resourceManager->registerJsFile($assetsPaths[1] . '/resource-smart-load.js', [
'depends' => [
\yii\web\JqueryAsset::className(),
\yii\web\YiiAsset::className()
]
]);
}
/**
* @inheritdoc
*/
protected function writeLog($msg)
{
\Yii::getLogger()->log($msg, \yii\log\Logger::LEVEL_INFO, 'resource-smart-load');
}
/**
* @inheritdoc
*/
protected function jsGlobalObjPublicPath()
{
return 'yii.resourceSmartLoad';
}
}