本文整理汇总了PHP中Assetic\Asset\StringAsset::setLastModified方法的典型用法代码示例。如果您正苦于以下问题:PHP StringAsset::setLastModified方法的具体用法?PHP StringAsset::setLastModified怎么用?PHP StringAsset::setLastModified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assetic\Asset\StringAsset
的用法示例。
在下文中一共展示了StringAsset::setLastModified方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTwoCollectionsHasDifferentCacheKey
public function testTwoCollectionsHasDifferentCacheKey()
{
$aggregateResolver = $this->getMock('AssetManager\\Resolver\\ResolverInterface');
//assets with same 'last modifled time'.
$now = time();
$bacon = new Asset\StringAsset('bacon');
$bacon->setLastModified($now);
$bacon->mimetype = 'text/plain';
$eggs = new Asset\StringAsset('eggs');
$eggs->setLastModified($now);
$eggs->mimetype = 'text/plain';
$assets = array(array('bacon', $bacon), array('eggs', $eggs));
$aggregateResolver->expects($this->any())->method('resolve')->will($this->returnValueMap($assets));
$resolver = new CollectionResolver(array('collection1' => array('bacon'), 'collection2' => array('eggs')));
$mimeResolver = new MimeResolver();
$assetFilterManager = new \AssetManager\Service\AssetFilterManager();
$assetFilterManager->setMimeResolver($mimeResolver);
$resolver->setAggregateResolver($aggregateResolver);
$resolver->setAssetFilterManager($assetFilterManager);
$collection1 = $resolver->resolve('collection1');
$collection2 = $resolver->resolve('collection2');
$cacheInterface = $this->getMock('Assetic\\Cache\\CacheInterface');
$cacheKeys = new \ArrayObject();
$callback = function ($key) use($cacheKeys) {
$cacheKeys[] = $key;
return true;
};
$cacheInterface->expects($this->exactly(2))->method('has')->will($this->returnCallback($callback));
$cacheInterface->expects($this->exactly(2))->method('get')->will($this->returnValue('cached content'));
$cache1 = new AssetCache($collection1, $cacheInterface);
$cache1->load();
$cache2 = new AssetCache($collection2, $cacheInterface);
$cache2->load();
$this->assertCount(2, $cacheKeys);
$this->assertNotEquals($cacheKeys[0], $cacheKeys[1]);
}
示例2: combineThenDump
public function combineThenDump()
{
// loop through leaves and add each raw asset
$parts = array();
$filtersAdded = $this->filters->all();
foreach ($this as $asset) {
if (!$filtersAdded) {
$this->filters = new FilterCollection($asset->getFilters());
$filtersAdded = true;
}
$parts[] = file_get_contents($asset->getSourceRoot() . '/' . $asset->getSourcePath());
}
$combinedAsset = new StringAsset(implode("\n", $parts), $this->filters->all());
$combinedAsset->setLastModified($this->getLastModified());
return $combinedAsset->dump();
}
示例3: testLastModified
public function testLastModified()
{
$asset = new StringAsset('');
$asset->setLastModified(123);
$this->assertEquals(123, $asset->getLastModified(), '->getLastModified() return the set last modified value');
}
示例4: createStringAsset
/**
* Create a string asset.
*
* @param array $filters The filters.
*
* @return StringAsset
*/
private function createStringAsset(array $filters)
{
$asset = new StringAsset($this->row['code'], $filters, TL_ROOT, 'string_asset');
$asset->setLastModified($this->row['tstamp']);
return $asset;
}
示例5: 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';
}