当前位置: 首页>>代码示例>>PHP>>正文


PHP StringAsset::setTargetPath方法代码示例

本文整理汇总了PHP中Assetic\Asset\StringAsset::setTargetPath方法的典型用法代码示例。如果您正苦于以下问题:PHP StringAsset::setTargetPath方法的具体用法?PHP StringAsset::setTargetPath怎么用?PHP StringAsset::setTargetPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Assetic\Asset\StringAsset的用法示例。


在下文中一共展示了StringAsset::setTargetPath方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testExternalSource

 public function testExternalSource()
 {
     $asset = new StringAsset('body { background: url(../images/bg.gif); }', array(), 'http://www.example.com', 'css/main.css');
     $asset->setTargetPath('css/packed/main.css');
     $asset->load();
     $filter = new CssRewriteFilter();
     $filter->filterDump($asset);
     $this->assertContains('http://www.example.com/css/../images/bg.gif', $asset->getContent(), '->filterDump() rewrites references in external stylesheets');
 }
开发者ID:artz20,项目名称:Tv-shows-zone,代码行数:9,代码来源:CssRewriteFilterTest.php

示例2: testUrls

 /**
  * @dataProvider provideUrls
  */
 public function testUrls($before, $after)
 {
     $asset = new StringAsset($before, array(), null, '.');
     $asset->setTargetPath('.');
     $asset->load();
     $filter = new CachebusterFilter('v=bar');
     $filter->filterDump($asset);
     $this->assertEquals($after, $asset->getContent());
 }
开发者ID:bluedogtraining,项目名称:assetic-extensions,代码行数:12,代码来源:CachebusterFilterTest.php

示例3: testEmptyUrl

 public function testEmptyUrl()
 {
     $asset = new StringAsset('body { background: url(); }', array(), 'http://www.example.com', 'css/main.css');
     $asset->setTargetPath('css/packed/main.css');
     $asset->load();
     $filter = new CssRewriteFilter();
     $filter->filterDump($asset);
     // no error is thrown
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:9,代码来源:CssRewriteFilterTest.php

示例4: testMultipleUrls

 /**
  * @dataProvider provideMultipleUrls
  */
 public function testMultipleUrls($format, $sourcePath, $targetPath, $inputUrl1, $inputUrl2, $expectedUrl1, $expectedUrl2)
 {
     $asset = new StringAsset(sprintf($format, $inputUrl1, $inputUrl2), array(), null, $sourcePath);
     $asset->setTargetPath($targetPath);
     $asset->load();
     $filter = new CssRewriteFilter();
     $filter->filterLoad($asset);
     $filter->filterDump($asset);
     $this->assertEquals(sprintf($format, $expectedUrl1, $expectedUrl2), $asset->getContent(), '->filterDump() rewrites relative urls');
 }
开发者ID:laiello,项目名称:mediathequescrum,代码行数:13,代码来源:CssRewriteFilterTest.php

示例5: testSimple

 public function testSimple()
 {
     $directory = $this->getMockBuilder('Alex\\AsseticExtraBundle\\Assetic\\Util\\AssetDirectory')->disableOriginalConstructor()->getMock();
     $directory->expects($this->any())->method('getTarget')->will($this->returnValue('assets'));
     $directory->expects($this->once())->method('add')->with('images/foo.png')->will($this->returnValue('assets/foo.png'));
     $filter = new AssetDirectoryFilter($directory);
     $asset = new StringAsset('body { background: url("../images/foo.png"); }', array($filter), null, 'css/main.css');
     $asset->setTargetPath('css/main.css');
     $asset->load();
     $filter->filterLoad($asset);
     $filter->filterDump($asset);
     $this->assertEquals('body { background: url("../assets/foo.png"); }', $asset->getContent(), 'AssetDirectoryFilter filters URL');
 }
开发者ID:alexandresalome,项目名称:assetic-extra-bundle,代码行数:13,代码来源:AsseticDirectoryFilterTest.php

示例6: getStringAsset

 /**
  * @param string $content
  * @param string $filename
  * @return StringAsset
  */
 private function getStringAsset($content, $filename)
 {
     $asset = new StringAsset($content);
     $asset->setTargetPath($filename);
     return $asset;
 }
开发者ID:jeroenvdheuvel,项目名称:assetic-cache-busting-worker,代码行数:11,代码来源:CacheBustingWorkerTest.php

示例7: createSimpleTestAsset

 private function createSimpleTestAsset()
 {
     $asset = new StringAsset('.hidden {display: none;}');
     $asset->setTargetPath('base.css');
     return $asset;
 }
开发者ID:rhysr,项目名称:zf2assetic,代码行数:6,代码来源:AssetControllerTest.php

示例8: processFile

 public function processFile($path, $config = [])
 {
     $rel = b::param('rel', false, $config);
     $url = b::param('url', false, $config);
     $useGlobalFilters = b::param('useGlobalFilters', true, $config);
     // get the file
     $file = $this->getFile($path);
     $root = pathinfo($path)['dirname'];
     $ext = pathinfo($path)['extension'];
     // get it's tree
     $content = $file->getContent();
     if (empty($content)) {
         return $content;
     }
     $inc = [];
     // parse the string
     $found = $this->parseString($content, $root);
     if (b::param('filterOnly', false, $config) === 'true') {
         $found = ['filter' => $found['filter']];
     }
     $tree = $this->getCombinedTree($found, $ext);
     $reduce = function ($items, $reduce) {
         $resp = [];
         foreach ($items as $key => $files) {
             $resp[] = $key;
             $resp += $reduce($files, $reduce);
         }
         return $resp;
     };
     // loop through each file and append
     foreach (array_unique($reduce($tree, $reduce)) as $f) {
         if ($f === $path) {
             continue;
         }
         $inc[] = $this->processFile($f);
     }
     $source = false;
     $sourcePath = false;
     $targetPath = false;
     if ($url) {
         $parts = parse_url($url);
         $source = "{$parts['scheme']}://{$parts['host']}";
         $targetPath = trim($parts['path'], '/');
         $sourcePath = $targetPath . '/' . trim($rel, '/');
     }
     $inc[] = $content;
     $a = new StringAsset(implode("\n", $inc), [], $source, $sourcePath);
     if ($targetPath) {
         $a->setTargetPath($targetPath);
     }
     // use filters
     if ($useGlobalFilters !== false) {
         if (array_key_exists($ext, $this->_filters)) {
             foreach ($this->_filters[$ext] as $filter) {
                 if ($filter[1] === false and b::env() === 'dev') {
                     continue;
                 }
                 $a->ensureFilter(new $filter[0]());
             }
         }
         foreach ($this->_filters['*'] as $filter) {
             if ($filter[1] === false and b::env() === 'dev') {
                 continue;
             }
             $a->ensureFilter(new $filter[0]());
         }
     }
     $a->ensureFilter(new CssRewriteFilter());
     return trim($a->dump());
 }
开发者ID:boltphp,项目名称:core,代码行数:70,代码来源:assets.php

示例9: filterResource

 /**
  * Filter resource.
  *
  * Filter resource, applying filters and saving output into output location.
  *
  * @param ResourceInterface $resource Resource to filter.
  * @return ResourceInterface Resulting filtered resources.
  */
 private function filterResource(ResourceInterface $resource, array $filters)
 {
     if ($resource instanceof FileResource) {
         $asset = new FileAsset($resource->getSource(), $filters);
     } elseif ($resource instanceof HttpResource) {
         $asset = new HttpAsset($resource->getSource(), $filters);
     } elseif ($resource instanceof StringResource) {
         $asset = new StringAsset($resource->getSource(), $filters, $resource->getSourceRoot());
     } else {
         throw new InvalidArgumentException(sprintf('Instance of "%s" expected, "%s" given.', implode('", "', array('RunOpenCode\\AssetsInjection\\Resource\\FileResource', 'RunOpenCode\\AssetsInjection\\Resource\\HttpResource', 'RunOpenCode\\AssetsInjection\\Resource\\StringResource')), get_class($resource)));
     }
     $asset->setTargetPath($this->calculateTargetFilename($resource));
     $path = sprintf('%s%s%s', $this->options['output_dir'], DIRECTORY_SEPARATOR, $asset->getTargetPath());
     if (!file_exists($path) || filectime($path) !== $resource->getLastModified()) {
         $this->assetWriter->writeAsset($asset);
         touch($path, $resource->getLastModified() ? $resource->getLastModified() : time());
     }
     return new FileResource($path);
 }
开发者ID:runopencode,项目名称:assets-injection,代码行数:27,代码来源:ProcessAssetsFiltersPass.php

示例10: run

 public function run()
 {
     /** @var RenderModeDeterminer $renderModeDeterminer */
     $renderModeDeterminer = $GLOBALS['container']['theme-plus-render-mode-determiner'];
     $renderMode = $renderModeDeterminer->determineMode();
     if (RenderMode::DESIGN == $renderMode) {
         $user = FrontendUser::getInstance();
         $user->authenticate();
         /** @var DeveloperTool $developerTool */
         $developerTool = $GLOBALS['container']['theme-plus-developer-tools'];
         $pathInfo = \Environment::get('pathInfo');
         list($type, $id) = explode('/', substr($pathInfo, 1));
         // output headers
         header("Cache-Control: public");
         switch ($type) {
             case 'css':
                 header('Content-Type: text/css; charset=utf-8');
                 break;
             case 'js':
                 header('Content-Type: text/javascript; charset=utf-8');
                 break;
         }
         if (isset($_SESSION['THEME_PLUS_ASSETS'][$id])) {
             $session = unserialize($_SESSION['THEME_PLUS_ASSETS'][$id]);
             // load asset from session
             /** @var AssetInterface $asset */
             $asset = $session->asset;
             /** @var AssetInterface $cache */
             $cache = $session->cache;
             if (false && $cache && $cache->getLastModified() >= $asset->getLastModified()) {
                 header('X-Theme-Plus-Rendering: cached');
                 echo $cache->getContent();
                 ob_flush();
                 return;
             }
             header('X-Theme-Plus-Rendering: live');
             // load page from session
             $GLOBALS['objPage'] = $page = \PageModel::findWithDetails($session->page);
             /** @var AsseticFactory $asseticFactory */
             $asseticFactory = $GLOBALS['container']['assetic.factory'];
             // default filter
             $defaultFilters = $asseticFactory->createFilterOrChain($page->layout->asseticStylesheetFilter, true);
             // remove css rewrite filter
             foreach ($defaultFilters as $index => $filter) {
                 if ($filter instanceof CssRewriteFilter) {
                     unset($defaultFilters[$index]);
                 }
             }
             // update the target path
             $asset->setTargetPath('assets/theme-plus/proxy.php/:type/:id/:name');
             // create debug informations
             $buffer = '/*' . PHP_EOL;
             $buffer .= ' * DEBUG' . PHP_EOL;
             $buffer .= $developerTool->getAssetDebugString($asset, ' * ') . PHP_EOL;
             $buffer .= ' * END' . PHP_EOL;
             $buffer .= ' */' . PHP_EOL . PHP_EOL;
             // dump the asset
             $buffer .= $asset->dump($defaultFilters);
             $cachedAsset = new StringAsset($buffer, [], $asset->getSourceRoot(), $asset->getSourcePath());
             $cachedAsset->setTargetPath($asset->getTargetPath());
             $cachedAsset->setLastModified($asset->getLastModified());
             $cachedAsset->load();
             $session->cache = $cachedAsset;
             $_SESSION['THEME_PLUS_ASSETS'][$id] = serialize($session);
             // update advanced asset cache meta
             if (!$GLOBALS['TL_CONFIG']['theme_plus_disabled_advanced_asset_caching']) {
                 /** @var Cache $cache */
                 $cache = $GLOBALS['container']['theme-plus-assets-cache'];
                 $latestTimestamp = $cache->fetch(ThemePlus::CACHE_LATEST_ASSET_TIMESTAMP);
                 if (!$latestTimestamp || $latestTimestamp < $asset->getLastModified()) {
                     $cache->save(ThemePlus::CACHE_LATEST_ASSET_TIMESTAMP, $asset->getLastModified());
                 }
             }
             echo $buffer;
             ob_flush();
             return;
         }
     }
     header('HTTP/1.1 403 Forbidden');
     header('Status: 403 Forbidden');
     header('Content-Type: text/plain; charset=UTF-8');
     echo '403 Forbidden';
 }
开发者ID:bit3,项目名称:contao-theme-plus,代码行数:83,代码来源:proxy.php


注:本文中的Assetic\Asset\StringAsset::setTargetPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。