public function resolve($asset, Asset $relative = null) { if ($relative) { return AssetFactory::fromAsset($relative, $asset); } return AssetFactory::fromUrl($asset, $this->_env); }
public function assetTimestamp($path) { try { return '/asset' . AssetFactory::fromUrl($path, $this->env)->digestUrl(); } catch (Exception $e) { return parent::assetTimestamp($path); } }
public function testFromUrl() { $result = AssetFactory::fromUrl('css/bundle.css', $this->path); $this->assertInstanceOf('CssAsset', $result); $result = AssetFactory::fromUrl('js/bundle.js', $this->path); $this->assertInstanceOf('JsAsset', $result); $result = AssetFactory::fromUrl('img/photo.jpg', $this->path); $this->assertInstanceOf('StaticAsset', $result); }
public function dispatch($url, CakeResponse $response) { try { $asset = AssetFactory::fromUrl($url, $this->_env); $this->_deliver($response, $asset); if (Configure::read('debug') == 0) { $File = new File(WWW_ROOT . 'asset' . DS . str_replace('/', DS, $asset->digestUrl()), true); $File->write($asset->content()); } } catch (Exception $e) { $response->statusCode(404); $response->send(); } return; }