本文整理匯總了PHP中Illuminate\Support\Facades\File::lastModified方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::lastModified方法的具體用法?PHP File::lastModified怎麽用?PHP File::lastModified使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Support\Facades\File
的用法示例。
在下文中一共展示了File::lastModified方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testServingFile
public function testServingFile()
{
$response = new StaticFileResponse($this->testFilePath);
$lastModified = new DateTime();
$lastModified->setTimestamp(File::lastModified($this->testFilePath));
$this->assertEquals($response->getStatusCode(), 200);
$this->assertEquals($response->getContent(), $this->testFileContent);
$this->assertEquals($response->getLastModified()->getTimestamp(), $lastModified->getTimestamp());
}
示例2: checkIncludesUniq
/**
* Pārbauda iekļauto JavaScript datņu unikalitāti un ievieto vēl neiekļautās norādes JavaScript masīvā
*
* @param array $inc_arr Bloka iekļauto JavaScript norāžu masīvs
*/
private function checkIncludesUniq($inc_arr)
{
foreach ($inc_arr as $inc) {
$inc = $inc . "?v=" . File::lastModified(public_path() . "/" . $inc);
if (!in_array($inc, $this->script_arr)) {
$this->script_arr[count($this->script_arr)] = $inc;
}
}
}
示例3: __construct
public function __construct($filePath)
{
parent::__construct();
if (!File::isFile($filePath)) {
throw new Exception("Cannot read file: {$filePath}");
}
$fileContent = file_get_contents($filePath);
$this->setContent($fileContent);
$lastModified = new DateTime();
$lastModified->setTimestamp(File::lastModified($filePath));
$this->setLastModified($lastModified);
$this->isNotModified(App::make('request'));
}
示例4: resize
/**
* Resize an image
* @param string $url
* @param integer $width
* @param integer $height
* @param boolean $crop
* @return string
*/
public function resize($url, $width = 100, $height = null, $crop = false, $quality = 90)
{
if ($url) {
// URL info
$info = pathinfo($url);
// The size
if (!$height) {
$height = $width;
}
// Quality
$quality = Config::get('redminportal::image.quality', $quality);
// Directories and file names
$fileName = $info['basename'];
$sourceDirPath = public_path() . '/' . $info['dirname'];
$sourceFilePath = $sourceDirPath . '/' . $fileName;
$targetDirName = $width . 'x' . $height . ($crop ? '_crop' : '');
$targetDirPath = $sourceDirPath . '/' . $targetDirName . '/';
$targetFilePath = $targetDirPath . $fileName;
$targetUrl = asset($info['dirname'] . '/' . $targetDirName . '/' . $fileName);
// Create directory if missing
try {
// Create dir if missing
if (!Filesystem::isDirectory($targetDirPath) and $targetDirPath) {
@Filesystem::makeDirectory($targetDirPath);
}
// Set the size
$size = new Box($width, $height);
// Now the mode
$mode = $crop ? ImageInterface::THUMBNAIL_OUTBOUND : ImageInterface::THUMBNAIL_INSET;
if (!Filesystem::exists($targetFilePath) or Filesystem::lastModified($targetFilePath) < Filesystem::lastModified($sourceFilePath)) {
$this->imagine->open($sourceFilePath)->thumbnail($size, $mode)->save($targetFilePath, array('quality' => $quality));
}
} catch (\Exception $e) {
Log::error('[IMAGE SERVICE] Failed to resize image "' . $url . '" [' . $e->getMessage() . ']');
}
return $targetUrl;
}
}
示例5: lastModified
/**
* Get file last modified
*
* @param string $filePath File path
* @return int Last modified time
*/
private function lastModified($filePath)
{
return File::lastModified($filePath);
}
示例6: combine
/**
* Combine the given array of assets. Minify, if enabled.
* Returns new array containing one asset.
*
* @param array $assets Array of assets.
* @param string $type File type (script, style).
*
* @return array
*/
public function combine(array $assets, $type)
{
$paths = array();
$lastmod = 0;
foreach ($assets as $asset) {
$paths[] = $asset['path'];
$mod = @File::lastModified($asset['path']);
if ($mod > $lastmod) {
$lastmod = $mod;
}
}
if ($this->show_refer) {
$file = $this->cache_path . '/casset-' . md5(implode(',', $paths) . $lastmod) . '-' . $this->name;
} else {
$file = $this->cache_path . '/' . md5(implode(',', $paths) . $lastmod);
}
$file .= 'script' === $type ? '.js' : '.css';
$combine = false;
if (!File::exists($file)) {
$combine = true;
} else {
if (File::lastModified($file) < $lastmod) {
$combine = true;
}
}
if ($combine) {
$content = '';
foreach ($assets as $asset) {
if (!File::exists($asset['path'])) {
continue;
}
$c = File::get($asset['path']);
if ($asset['ext'] == 'css' && preg_match_all('~url\\(([\\"\'^\\)]*)?([^\\)]*)([\\"\'^\\)]*)?\\)~i', $c, $match)) {
foreach ($match[2] as $row => $link) {
$link = UrlFormat::toAbsolute(asset($asset['url']), $link);
$c = str_replace($match[0][$row], 'url("' . preg_replace('~^https?:~i', '', $link) . '")', $c);
}
}
if ($this->minify && !(stripos($asset['source'], '.min') || stripos($asset['source'], '-min'))) {
switch ($type) {
case 'style':
$min = new \CSSmin();
$c = $min->run($c);
#$c = Compressors\Css::process($c);
break;
case 'script':
$c = \JSMin::minify($c);
#$c = Compressors\Js::minify($c);
break;
}
}
if ($this->show_refer) {
$content .= "/* {$asset['source']} */\n{$c}\n\n";
} else {
$content .= "/* --- */\n{$c}\n\n";
}
}
File::put($file, $content);
}
return array(array('path' => $file, 'attributes' => array(), 'url' => str_ireplace($this->public_path, '', $file)));
}
示例7: combine
/**
* Combine the given array of assets. Minify, if enabled.
* Returns new array containing one asset.
*
* @param array $assets Array of assets.
* @param string $type File type (script, style).
*
* @return array
*/
public function combine(array $assets, $type)
{
$paths = array();
$lastmod = 0;
foreach ($assets as $asset) {
$paths[] = $asset['path'];
$mod = File::lastModified($asset['path']);
if ($mod > $lastmod) {
$lastmod = $mod;
}
}
$file = $this->cache_path . '/casset-' . md5(implode(',', $paths) . $lastmod) . '-' . $this->name;
$file .= 'script' === $type ? '.js' : '.css';
$combine = false;
if (!File::exists($file)) {
$combine = true;
} else {
if (File::lastModified($file) < $lastmod) {
$combine = true;
}
}
if ($combine) {
$content = '';
foreach ($assets as $asset) {
if (!File::exists($asset['path'])) {
continue;
}
$c = File::get($asset['path']);
if ($this->minify && !(stripos($asset['source'], '.min') || stripos($asset['source'], '-min'))) {
switch ($type) {
case 'style':
$c = Compressors\Css::process($c);
break;
case 'script':
$c = Compressors\Js::minify($c);
break;
}
}
$content .= "/* {$asset['source']} */\n{$c}\n\n";
}
File::put($file, $content);
}
return array(array('path' => $file, 'attributes' => array(), 'url' => str_ireplace($this->public_path, '', $file)));
}