mirror of
				https://github.com/Icinga/icinga-php-library.git
				synced 2025-10-31 03:03:54 +01:00 
			
		
		
		
	AssetLoader: Allow to make copies of assets
This commit is contained in:
		
							parent
							
								
									ffd1e1d5a3
								
							
						
					
					
						commit
						d11bbb0f52
					
				| @ -7,8 +7,10 @@ class AssetLoader | |||||||
|         'asset/css'                 => 'vendor/fortawesome/font-awesome/css/fontawesome.css' |         'asset/css'                 => 'vendor/fortawesome/font-awesome/css/fontawesome.css' | ||||||
|     ]; |     ]; | ||||||
| 
 | 
 | ||||||
|     public static function update() |     public static function update(Composer\Script\Event $event) | ||||||
|     { |     { | ||||||
|  |         $copy = in_array('copy-assets', $event->getArguments(), true); | ||||||
|  | 
 | ||||||
|         if (is_dir('asset')) { |         if (is_dir('asset')) { | ||||||
|             // Check for removed files
 |             // Check for removed files
 | ||||||
|             $fs = new Composer\Util\Filesystem(); |             $fs = new Composer\Util\Filesystem(); | ||||||
| @ -48,7 +50,11 @@ class AssetLoader | |||||||
|                     if ($asset->isDir()) { |                     if ($asset->isDir()) { | ||||||
|                         mkdir($relativePath, 0755, true); |                         mkdir($relativePath, 0755, true); | ||||||
|                     } elseif ($asset->isFile()) { |                     } elseif ($asset->isFile()) { | ||||||
|                         symlink($asset->getPathname(), $relativePath); |                         if ($copy) { | ||||||
|  |                             copy($asset->getPathname(), $relativePath); | ||||||
|  |                         } else { | ||||||
|  |                             symlink($asset->getPathname(), $relativePath); | ||||||
|  |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @ -79,7 +85,11 @@ class AssetLoader | |||||||
|                     '/\\' |                     '/\\' | ||||||
|                 )]); |                 )]); | ||||||
|                 if (! file_exists($relativePath) && $awesomeFile->isFile()) { |                 if (! file_exists($relativePath) && $awesomeFile->isFile()) { | ||||||
|                     symlink($awesomeFile->getPathname(), $relativePath); |                     if ($copy) { | ||||||
|  |                         copy($awesomeFile->getPathname(), $relativePath); | ||||||
|  |                     } else { | ||||||
|  |                         symlink($awesomeFile->getPathname(), $relativePath); | ||||||
|  |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user