Stump Assets
  • Namespace
  • Class
  • Tree
  • Todo
  • Download

Namespaces

  • Skimia
    • Assets
      • Console
        • Commands
      • Events
      • Providers
      • Scanner

Classes

  • Skimia\Assets\AssetsServiceProvider
  • Skimia\Assets\Console\Commands\DumpCollectionsCommand
  • Skimia\Assets\Console\Commands\FlushPipelineCommand
  • Skimia\Assets\Events\BeforeMergeCollectionFiles
  • Skimia\Assets\Manager
  • Skimia\Assets\Providers\StolzAssetsServiceProvider
  • Skimia\Assets\Scanner\Scanner
  • Skimia\Assets\Scanner\ScannerServiceProvider
 1 <?php
 2 
 3 namespace Skimia\Assets;
 4 
 5 use Stolz\Assets\Manager as ManagerBase;
 6 
 7 class Manager extends ManagerBase
 8 {
 9     protected $collections_dir = 'collections';
10 
11     /**
12      * Set up configuration options.
13      *
14      * All the class properties except 'js' and 'css' are accepted here.
15      * Also, an extra option 'autoload' may be passed containing an array of
16      * assets and/or collections that will be automatically added on startup.
17      *
18      * @param  array   $config Configurable options.
19      * @return Manager
20      */
21     public function config(array $config)
22     {
23         if (isset($config['collections_dir'])) {
24             $this->collections_dir = $config['collections_dir'];
25         } else {
26             return parent::config($config); // @codeCoverageIgnore
27         }
28     }
29 
30     /**
31      * Determine whether an asset is normal or from an asset collection.
32      *
33      * @param  string $asset
34      * @return bool|array
35      */
36     protected function assetIsFromCollection($asset)
37     {
38         if (preg_match('{^([A-Za-z0-9_.-]+)\#(.*)$}', $asset, $matches)) {
39             return array_slice($matches, 1, 2);
40         }
41 
42         return false;
43     }
44 
45     /**
46      * Build link to local asset.
47      *
48      * Detects packages links.
49      *
50      * @param  string $asset
51      * @param  string $dir
52      * @return string the link
53      */
54     protected function buildLocalLink($asset, $dir)
55     {
56         $collection = $this->assetIsFromCollection($asset);
57         if ($collection !== false) {
58             return $this->collections_dir.'/'.$collection[0].'/'.ltrim($dir, '/').'/'.$collection[1];
59         }
60 
61         return parent::buildLocalLink($asset, $dir);
62     }
63 
64     public function getCollections()
65     {
66         return $this->collections;
67     }
68 }
69 
Stump Assets API documentation generated by ApiGen