本文整理汇总了PHP中Assetic\Asset\AssetCollection::load方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetCollection::load方法的具体用法?PHP AssetCollection::load怎么用?PHP AssetCollection::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assetic\Asset\AssetCollection
的用法示例。
在下文中一共展示了AssetCollection::load方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
public function load(FilterInterface $additionalFilter = null)
{
if (!$this->initialized) {
$this->initialize();
}
parent::load($additionalFilter);
}
示例2: runResolve
public function runResolve(framework\Request $request)
{
$theme = isset($request['theme_name']) ? $request['theme_name'] : framework\Settings::getThemeName();
if ($request->hasParameter('css')) {
$this->getResponse()->setContentType('text/css');
if (!$request->hasParameter('theme_name')) {
$basepath = THEBUGGENIE_PATH . 'public' . DS . 'css';
$asset = THEBUGGENIE_PATH . 'public' . DS . 'css' . DS . $request->getParameter('css');
} else {
$basepath = THEBUGGENIE_PATH . 'themes';
$asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'css' . DS . $request->getParameter('css');
}
} elseif ($request->hasParameter('js')) {
$this->getResponse()->setContentType('text/javascript');
if ($request->hasParameter('theme_name')) {
$basepath = THEBUGGENIE_PATH . 'themes';
$asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'js' . DS . $request->getParameter('js');
} elseif ($request->hasParameter('module_name') && framework\Context::isModuleLoaded($request['module_name'])) {
$module_path = framework\Context::isInternalModule($request['module_name']) ? THEBUGGENIE_INTERNAL_MODULES_PATH : THEBUGGENIE_MODULES_PATH;
$basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'js';
$asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'js' . DS . $request->getParameter('js');
} else {
$basepath = THEBUGGENIE_PATH . 'public' . DS . 'js';
$asset = THEBUGGENIE_PATH . 'public' . DS . 'js' . DS . $request->getParameter('js');
}
} else {
throw new \Exception('The expected theme Asset type is not supported.');
}
$fileAsset = new AssetCollection(array(new FileAsset($asset, array(), $basepath)));
$fileAsset->load();
// Do not decorate the asset with the theme's header/footer
$this->getResponse()->setDecoration(framework\Response::DECORATE_NONE);
return $this->renderText($fileAsset->dump());
}
示例3: load
/**
* {@inheritdoc}
*/
public function load(FilterInterface $additionalFilter = null)
{
if (!$this->loaded) {
$this->loadResourcesFromRepo();
}
parent::load($additionalFilter);
}
示例4: execute
/**
* @see Command
*
* @throws \InvalidArgumentException When the target directory does not exist
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->getContainer()->get('kernel')->getRootDir();
$targetArg = rtrim($input->getArgument('target'), '/') . '/';
$rootDir = $this->getContainer()->get('kernel')->getRootDir();
$targetDir = $rootDir . '/../' . $targetArg;
$confDir = $rootDir . '/config';
if (!is_dir($targetDir)) {
throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target')));
}
if (!file_exists($confDir . '/assets.json')) {
throw new \InvalidArgumentException('The file ' . $confDir . '/assets.json does not exist.');
}
$output->writeln("Combining assets");
$assetsFiles = json_decode(file_get_contents($confDir . '/assets.json'), true);
foreach ($assetsFiles as $type => $combined) {
foreach ($combined as $name => $files) {
file_put_contents($targetDir . $files['output'], '');
$this->assets[$type][$name] = (array) $files['input'];
foreach ($this->assets[$type][$name] as $value) {
file_put_contents($targetDir . $files['output'], file_get_contents($targetDir . $value), FILE_APPEND);
}
$file = $targetDir . $files['output'];
if (is_file($file)) {
$f = new File($file);
switch ($f->getExtension()) {
case 'css':
$resource = new AssetCollection(array(new FileAsset($file)), array(new MinifyCssCompressorFilter()));
$resource->load();
file_put_contents($file, $resource->dump());
$output->writeln(sprintf('File <comment>%s</comment> was combined and minified', $file));
break;
case 'js':
$resource = new AssetCollection(array(new FileAsset($file)), array(new JSMinPlusFilter()));
$resource->load();
file_put_contents($file, $resource->dump());
$output->writeln(sprintf('File <comment>%s</comment> was combined and minified', $file));
break;
}
}
}
}
}
示例5: testDumpDedupByStrictEquality
public function testDumpDedupByStrictEquality()
{
$asset = new StringAsset('foo');
$coll = new AssetCollection(array($asset, $asset));
$coll->load();
$this->assertEquals('foo', $coll->dump(), '->dump() detects duplicate assets based on strict equality');
}
示例6: runResolve
public function runResolve(framework\Request $request)
{
$theme = isset($request['theme_name']) ? $request['theme_name'] : framework\Settings::getThemeName();
$module_path = framework\Context::isInternalModule($request['module_name']) ? THEBUGGENIE_INTERNAL_MODULES_PATH : THEBUGGENIE_MODULES_PATH;
if ($request->hasParameter('css')) {
$this->getResponse()->setContentType('text/css');
if ($request->hasParameter('module_name') && framework\Context::isModuleLoaded($request['module_name'])) {
$basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'css';
$asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'css' . DS . $request->getParameter('css');
} elseif (!$request->hasParameter('theme_name')) {
$basepath = THEBUGGENIE_PATH . 'public' . DS . 'css';
$asset = THEBUGGENIE_PATH . 'public' . DS . 'css' . DS . $request->getParameter('css');
} else {
$basepath = THEBUGGENIE_PATH . 'themes';
$asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'css' . DS . $request->getParameter('css');
}
} elseif ($request->hasParameter('js')) {
$this->getResponse()->setContentType('text/javascript');
if ($request->hasParameter('theme_name')) {
$basepath = THEBUGGENIE_PATH . 'themes';
$asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'js' . DS . $request->getParameter('js');
} elseif ($request->hasParameter('module_name') && framework\Context::isModuleLoaded($request['module_name'])) {
$basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'js';
$asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'js' . DS . $request->getParameter('js');
} else {
$basepath = THEBUGGENIE_PATH . 'public' . DS . 'js';
$asset = THEBUGGENIE_PATH . 'public' . DS . 'js' . DS . $request->getParameter('js');
}
} elseif ($request->hasParameter('image')) {
$basepath = THEBUGGENIE_PATH . 'themes';
$asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'images';
if (isset($request['module_name'])) {
$asset .= DS . "modules" . DS . $request['module_name'];
}
if (isset($request['folder'])) {
$asset .= DS . $request['folder'];
}
$asset .= DS . $request->getParameter('image');
if (!file_exists($asset) && isset($request['module_name']) && framework\Context::isModuleLoaded($request['module_name'])) {
$basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'images';
$asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'images';
if (isset($request['folder'])) {
$asset .= DS . $request['folder'];
}
$asset .= DS . $request->getParameter('image');
}
$fileinfo = finfo_open(FILEINFO_MIME_TYPE);
$mimetype = finfo_file($fileinfo, $asset);
finfo_close($fileinfo);
$this->getResponse()->setContentType($mimetype);
} else {
throw new \Exception('The expected theme Asset type is not supported.');
}
$last_modified = filemtime($asset);
$this->getResponse()->addHeader('Cache-Control: max-age=3600, must-revalidate');
$this->getResponse()->addHeader('Last-Modified: ' . gmdate('D, d M Y H:i:s ', $last_modified) . 'GMT');
$this->getResponse()->addHeader('ETag: ' . md5($last_modified));
if (!$this->getResponse()->isModified($last_modified)) {
return $this->return304();
}
$fileAsset = new AssetCollection(array(new FileAsset($asset, array(), $basepath)));
$fileAsset->load();
// Do not decorate the asset with the theme's header/footer
$this->getResponse()->setDecoration(framework\Response::DECORATE_NONE);
return $this->renderText($fileAsset->dump());
}