In Yii 1, you could publish an asset using:
Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.MyWidget.assets'));
How to publish an asset to a widget in Yii2?
Thank you for your help, this was the final code to solve the problem:
list($path, $webPath) = Yii::$app->getAssetManager()->publish(__DIR__."/assets); $this->getView()->registerJsFile($webPath);
In the field of view of your widget:
app\assets\AppAsset::register($this); // $this == the View object
Mark the documents .
:
app\assets\AppAsset::register($this->getView());
.
Yii::$app->getAssetManager()->publish('/path/to/assets'); // you can use an alias
http://www.yiiframework.com/doc-2.0/yii-web-assetmanager.html#publish()-detail
css js, , : http://www.yiiframework.com/doc-2.0/guide-structure-assets.html#defining-asset-bundles
Yii2 AssetBandle , -. Yii1 . .
(yii\web\AssetBundle) , , . . :
YourAsset::register($view);
$view->registerAssetBundle(InterrogateDeviceButtonAsset::class);
BaseController.php, . .
BaseController.php
/** * Publish an asset and return url * * @param $src * * @return mixed */ public function publishAsset( $src ) { $path = Yii::getAlias( $src ); if ( ! $this->assetManager ) { $this->assetManager = new AssetManager(); } $return = $this->assetManager->publish( $path ); return $return[1]; }
The only thing I'm trying to configure is to enable the full URL scheme. I posted my question that here the Yii2 AssetManager Published Path includes a URL scheme
Source: https://habr.com/ru/post/1570190/More articles:доступ ко всем элементам записи с использованием RTTI - rttiAndroid adds fragment inside fragment - androidКраткий сборник Laravel - sqlHow to access record properties? - rttiКак относится модель EF6 и модель WebAPI 2.2 + OData 4.0? - odataPyQt: Cover dialog from QDesigner and Connect button - pythonYii2 AssetManager Published Path Includes URL Schema - yii2Livereload on Rails does not show SCSS changes - sassWeb API authorization attribute not working in action - asp.nethttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1570195/how-to-load-vba-macros-to-the-excel-file-from-a-text-file-by-a-c-code&usg=ALkJrhjSpwwBZIhheC3LgiV6DtwoBqvTVwAll Articles