本文整理汇总了PHP中Assetic\Asset\AssetCollection::getLastModified方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetCollection::getLastModified方法的具体用法?PHP AssetCollection::getLastModified怎么用?PHP AssetCollection::getLastModified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assetic\Asset\AssetCollection
的用法示例。
在下文中一共展示了AssetCollection::getLastModified方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLastModified
public function getLastModified()
{
if (!$this->initialized) {
$this->initialize();
}
return parent::getLastModified();
}
示例2: createGroup
/**
* Create a new AssetCollection instance for the given group.
*
* @param string $name
* @param bool $overwrite force writing
* @return \Assetic\Asset\AssetCollection
*/
public function createGroup($name, $overwrite = false)
{
if (isset($this->groups[$name])) {
return $this->groups[$name];
}
$assets = $this->createAssetArray($name);
$filters = $this->createFilterArray($name);
$coll = new AssetCollection($assets, $filters);
if ($output = $this->getConfig($name, 'output')) {
$coll->setTargetPath($output);
}
// check output cache
$write_output = true;
if (!$overwrite) {
if (file_exists($output = public_path($coll->getTargetPath()))) {
$output_mtime = filemtime($output);
$asset_mtime = $coll->getLastModified();
if ($asset_mtime && $output_mtime >= $asset_mtime) {
$write_output = false;
}
}
}
// store assets
if ($overwrite || $write_output) {
$writer = new AssetWriter(public_path());
$writer->writeAsset($coll);
}
return $this->groups[$name] = $coll;
}
示例3: jsPackAction
public function jsPackAction()
{
$collection = new AssetCollection();
foreach ($this->container->getParameter('cms.cms_resources.js_pack') as $asset) {
$collection->add(new FileAsset($asset));
}
$content = $this->container->getCache()->fetch('cms_assets', 'js_pack', function () use($collection) {
return $collection->dump();
}, $collection->getLastModified());
return new Response($content, 200, array('Content-Type' => 'text/javascript'));
}
示例4: getAsseticAssets
protected function getAsseticAssets($onlyTypes = [], $onlySections = [])
{
$return = [];
$onlyTypes = $this->getKeysIfEmpty($this->collections, $onlyTypes);
foreach ($onlyTypes as $type) {
if (!isset($this->collections[$type])) {
continue;
}
$onlySections = $this->getKeysIfEmpty($this->collections[$type], $onlySections);
foreach ($onlySections as $section) {
if (!isset($this->collections[$type][$section])) {
continue;
} else {
$collections = $this->collections[$type][$section];
}
/**
* Sort collections by priority.
*/
ksort($collections);
foreach ($collections as $priority => $collection) {
$typePath = path('storage') . 'cache' . path('ds') . 'www' . path('ds') . $type . path('ds');
$assetCollection = new AssetCollection([], [], $typePath);
foreach ($collection as $asset) {
$filters = [];
if ($type == 'less') {
$filters[] = new LessPckgFilter();
$filters[] = new PathPckgFilter();
}
if (in_array($type, ['css', 'less'])) {
$filters[] = new PathPckgFilter();
}
$assetCollection->add(new FileAsset($asset, $filters));
}
$lastModified = $assetCollection->getLastModified();
$cachePath = $typePath . $priority . '-' . $section . '-' . $lastModified . '.' . $type;
$assetCollection->setTargetPath($cachePath);
file_put_contents($cachePath, $assetCollection->dump());
$return[] = str_replace('##LINK##', str_replace(path('root'), path('ds'), $cachePath), $this->types[$type]);
}
}
}
return $return;
}
示例5: testEmptyMtime
public function testEmptyMtime()
{
$coll = new AssetCollection();
$this->assertNull($coll->getLastModified(), '->getLastModified() returns null on empty collection');
}
示例6: testGetLastModified
/**
* @dataProvider getTimestampsAndExpected
*/
public function testGetLastModified($timestamps, $expected)
{
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
for ($i = 0; $i < count($timestamps); $i++) {
$asset->expects($this->at($i))
->method('getLastModified')
->will($this->returnValue($timestamps[$i]));
}
$coll = new AssetCollection(array_fill(0, count($timestamps), $asset));
$this->assertEquals($expected, $coll->getLastModified(), '->getLastModifed() returns the highest last modified');
}
示例7: getLastModified
/**
* {@inheritdoc}
*/
public function getLastModified()
{
if (!$this->loaded) {
$this->loadResourcesFromRepo();
}
return parent::getLastModified();
}
示例8: assetic
protected function assetic($files, $type)
{
$urls = [];
foreach ($files as $key => $file) {
$assetType = $this->parseInput($file);
if ($assetType == 'http') {
$urls[] = $file;
unset($files[$key]);
}
}
if (empty($files)) {
return $urls;
}
$name = md5(implode(',', $files)) . '.' . $type;
$cachePath = $this->config['paths']['pcache'];
$cache = $this->config['paths']['cache'];
$cachedFile = $this->config['locations']['cache'] . $name;
$file = $cachePath . $name;
$debug = $this->config['debug'];
if (!$debug && file_exists($file)) {
$urls[] = $cachedFile;
return $urls;
}
$aw = new AssetWriter($cachePath);
$am = new AssetManager();
// Create the collection
$collection = new AssetCollection();
// Create the cache
$cache = new FilesystemCache($cache);
foreach ($files as $file) {
$assetType = $this->parseInput($file);
// Create the asset
if ($assetType == 'file') {
$asset = new FileAsset($file);
} elseif ($assetType == 'glob') {
$asset = new GlobAsset($file);
} elseif ($assetType == 'http') {
$asset = new HttpAsset($file);
} elseif ($assetType == 'reference') {
$asset = new AssetReference($am, substr($file, 1));
}
$filters = $this->getFilters($file);
if (!empty($filters)) {
foreach ($filters as $filter) {
// Add the filter
$asset->ensureFilter($filter);
}
}
// Cache the asset so we don't have to reapply filters on future page loads
$cachedAsset = new AssetCache($asset, $cache);
// Add the cached asset to the collection
$collection->add($cachedAsset);
}
if (!file_exists($file) || $collection->getLastModified() > filemtime($file)) {
$am->set($type, $collection);
$am->get($type)->setTargetPath($name);
$aw->writeManagerAssets($am);
}
$urls[] = $cachedFile;
return $urls;
}