mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 06:37:55 +08:00 
			
		
		
		
	Update Russian translation of structure-assets.md (#18243)
This commit is contained in:
		@ -118,6 +118,29 @@ namespace app\assets;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
use yii\web\AssetBundle;
 | 
					use yii\web\AssetBundle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class FontAwesomeAsset extends AssetBundle 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public $sourcePath = '@bower/font-awesome'; 
 | 
				
			||||||
 | 
					    public $css = [ 
 | 
				
			||||||
 | 
					        'css/font-awesome.min.css', 
 | 
				
			||||||
 | 
					    ]; 
 | 
				
			||||||
 | 
					    public $publishOptions = [
 | 
				
			||||||
 | 
					        'only' => [
 | 
				
			||||||
 | 
					            'fonts/*',
 | 
				
			||||||
 | 
					            'css/*',
 | 
				
			||||||
 | 
					        ]
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					}  
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Более сложную логику можно реализовать с помощью переопределения `init()`. Ниже указан пример публикации поддиректорий этим способом:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```php
 | 
				
			||||||
 | 
					<?php
 | 
				
			||||||
 | 
					namespace app\assets;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use yii\web\AssetBundle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class FontAwesomeAsset extends AssetBundle 
 | 
					class FontAwesomeAsset extends AssetBundle 
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public $sourcePath = '@bower/font-awesome'; 
 | 
					    public $sourcePath = '@bower/font-awesome'; 
 | 
				
			||||||
@ -129,7 +152,10 @@ class FontAwesomeAsset extends AssetBundle
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        parent::init();
 | 
					        parent::init();
 | 
				
			||||||
        $this->publishOptions['beforeCopy'] = function ($from, $to) {
 | 
					        $this->publishOptions['beforeCopy'] = function ($from, $to) {
 | 
				
			||||||
            $dirname = basename(dirname($from));
 | 
					            if (basename(dirname($from)) !== 'font-awesome') {
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            $dirname = basename($from);
 | 
				
			||||||
            return $dirname === 'fonts' || $dirname === 'css';
 | 
					            return $dirname === 'fonts' || $dirname === 'css';
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user