/** * Register the asset manager itself, which is responsible for holding all * assets and compiling them. * * @return void */ protected function registerAssetManager() { // The assets and views parts actually take the theme bag as // their dependencies. They do this so that all themes in // the bag may be used when finding views and assets. $me = $this; $this->app['theme.assets'] = $this->app->share(function ($app) use($me) { $publicPath = $app['path.public']; $config = $app['config']->get('cartalyst.themes'); $manager = new AssetManager($app['themes'], $app['view.finder'], $app['theme.locations']); $manager->setDebug($me->guessDebug()); $manager->setCachePath(array_get($config, 'cache_path', null)); foreach (array_get($config, 'filters', array()) as $extension => $filters) { foreach ($filters as $filter) { $manager->addFilter($extension, $filter); } } $manager->setForceRecompile(array_get($config, 'force_recompile', false)); $manager->clearAssets(array_get($config, 'auto_clear', false)); return $manager; }); }
public function testFilters() { $manager = new AssetManager($themeBag = $this->getMockThemeBag(), $viewFinder = m::mock('Cartalyst\\Themes\\Views\\ViewFinderInterface'), $locationGenerator = m::mock('Cartalyst\\Themes\\Locations\\GeneratorInterface')); $this->assertCount(0, $manager->getFilterInstances('foo')); $manager->addFilter('foo', function () { return new FilterStubEmpty(); }); $manager->addFilter('foo', function () { return new FilterStub(); }); $this->assertCount(2, $filters = $manager->getFilterInstances('foo')); $this->assertInstanceOf('FilterStubEmpty', reset($filters)); $this->assertInstanceOf('FilterStub', end($filters)); }