本文整理汇总了PHP中Kohana::_files_changed方法的典型用法代码示例。如果您正苦于以下问题:PHP Kohana::_files_changed方法的具体用法?PHP Kohana::_files_changed怎么用?PHP Kohana::_files_changed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kohana
的用法示例。
在下文中一共展示了Kohana::_files_changed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: find_file
/**
* Searches for a file in the [Cascading Filesystem](kohana/files), and
* returns the path to the file that has the highest precedence, so that it
* can be included.
*
* When searching the "config", "messages", or "i18n" directories, or when
* the `$array` flag is set to true, an array of all the files that match
* that path in the [Cascading Filesystem](kohana/files) will be returned.
* These files will return arrays which must be merged together.
*
* If no extension is given, the default extension (`EXT` set in
* `index.php`) will be used.
*
* // Returns an absolute path to views/template.php
* Kohana::find_file('views', 'template');
*
* // Returns an absolute path to media/css/style.css
* Kohana::find_file('media', 'css/style', 'css');
*
* // Returns an array of all the "mimes" configuration files
* Kohana::find_file('config', 'mimes');
*
* @param string $dir directory name (views, i18n, classes, extensions, etc.)
* @param string $file filename with subdirectory
* @param string $ext extension to search for
* @param boolean $array return an array of files?
* @param string $theme theme name or defaults to active
* @return array a list of files when $array is TRUE
* @return string single file path
*/
public static function find_file($dir, $file, $ext = NULL, $array = FALSE, $theme = NULL)
{
if ($ext === NULL) {
// Use the default extension
$ext = EXT;
} elseif ($ext) {
// Prefix the extension with a period
$ext = ".{$ext}";
} else {
// Use no extension
$ext = '';
}
//theme class may not be available during initial init phase
if ($theme === NULL and class_exists('Theme')) {
// Use the active theme
$theme = Theme::$active;
}
// Create a partial path of the filename
$path = $dir . DS . $file . $ext;
if (Kohana::$caching === TRUE and isset(Kohana::$_files[$path . ($array ? '_array' : '_path')][$theme])) {
// This path has been cached
return Kohana::$_files[$path . ($array ? '_array' : '_path')][$theme];
}
if (Kohana::$profiling === TRUE and class_exists('Profiler', FALSE)) {
// Start a new benchmark
$benchmark = Profiler::start('Kohana', __FUNCTION__);
}
if ($array or $dir === 'config' or $dir === 'i18n' or $dir === 'messages') {
// Include paths must be searched in reverse
$paths = array_reverse(Kohana::$_paths);
// Array of files that have been found
$found = array();
foreach ($paths as $dir) {
if (is_file($dir . $path)) {
// This path has a file, add it to the list
$found[] = $dir . $path;
}
}
} else {
// The file has not been found yet
$found = FALSE;
foreach (Kohana::$_paths as $dir) {
if (is_file($dir . $path)) {
// A path has been found
$found = $dir . $path;
// Stop searching
break;
}
}
}
if (Kohana::$caching === TRUE) {
// Add the path to the cache
Kohana::$_files[$path . ($array ? '_array' : '_path')][$theme] = $found;
// Files have been changed
Kohana::$_files_changed = TRUE;
}
if (isset($benchmark)) {
// Stop the benchmark
Profiler::stop($benchmark);
}
return $found;
}
示例2: find_file
/**
* Finds the path of a file by directory, filename, and extension.
* If no extension is given, the default EXT extension will be used.
*
* When searching the "config" or "i18n" directories, or when the
* $aggregate_files flag is set to true, an array of files
* will be returned. These files will return arrays which must be
* merged together.
*
* // Returns an absolute path to views/template.php
* Kohana::find_file('views', 'template');
*
* // Returns an absolute path to media/css/style.css
* Kohana::find_file('media', 'css/style', 'css');
*
* // Returns an array of all the "mimes" configuration file
* Kohana::find_file('config', 'mimes');
*
* @param string directory name (views, i18n, classes, extensions, etc.)
* @param string filename with subdirectory
* @param string extension to search for
* @param boolean return an array of files?
* @return array a list of files when $array is TRUE
* @return string single file path
*/
public static function find_file($dir, $file, $ext = NULL, $array = FALSE)
{
// Use the defined extension by default
$ext = $ext === NULL ? EXT : '.' . $ext;
// Create a partial path of the filename
$path = $dir . DIRECTORY_SEPARATOR . $file . $ext;
if (Kohana::$caching === TRUE and isset(Kohana::$_files[$path])) {
// This path has been cached
return Kohana::$_files[$path];
}
if (Kohana::$profiling === TRUE and class_exists('Profiler', FALSE)) {
// Start a new benchmark
$benchmark = Profiler::start('Kohana', __FUNCTION__);
}
if ($array or $dir === 'config' or $dir === 'i18n' or $dir === 'messages') {
// Include paths must be searched in reverse
$paths = array_reverse(Kohana::$_paths);
// Array of files that have been found
$found = array();
foreach ($paths as $dir) {
if (is_file($dir . $path)) {
// This path has a file, add it to the list
$found[] = $dir . $path;
}
}
} else {
// The file has not been found yet
$found = FALSE;
foreach (Kohana::$_paths as $dir) {
if (is_file($dir . $path)) {
// A path has been found
$found = $dir . $path;
// Stop searching
break;
}
}
}
if (Kohana::$caching === TRUE) {
// Add the path to the cache
Kohana::$_files[$path] = $found;
// Files have been changed
Kohana::$_files_changed = TRUE;
}
if (isset($benchmark)) {
// Stop the benchmark
Profiler::stop($benchmark);
}
return $found;
}
示例3: find_file
/**
* Searches for a file in the [Cascading Filesystem](kohana/files), and
* returns the path to the file that has the highest precedence, so that it
* can be included.
*
* When searching the "config", "messages", or "i18n" directories, or when
* the `$array` flag is set to true, an array of all the files that match
* that path in the [Cascading Filesystem](kohana/files) will be returned.
* These files will return arrays which must be merged together.
*
* If no extension is given, the default extension (`EXT` set in
* `index.php`) will be used.
*
* // Returns an absolute path to views/template.php
* Kohana::find_file('views', 'template');
*
* // Returns an absolute path to media/css/style.scss
* Kohana::find_file('media', 'css/style', 'css');
*
* // Returns an array of all the "mimes" configuration files
* Kohana::find_file('config', 'mimes');
*
* @param string $dir directory name (views, i18n, classes, extensions, etc.)
* @param string $file filename with subdirectory
* @param string $ext extension to search for
* @param boolean $array return an array of files?
*
* @return array a list of files when $array is TRUE
* @return string single file path
*/
public static function find_file($dir, $file, $ext = null, $array = false)
{
if ($ext === null) {
// Use the default extension
$ext = EXT;
} elseif ($ext) {
// Prefix the extension with a period
$ext = ".{$ext}";
} else {
// Use no extension
$ext = '';
}
// Create a partial path of the filename
$path = $dir . DIRECTORY_SEPARATOR . $file . $ext;
if (Kohana::$caching === true and isset(Kohana::$_files[$path . ($array ? '_array' : '_path')])) {
// This path has been cached
return Kohana::$_files[$path . ($array ? '_array' : '_path')];
}
if (Kohana::$profiling === true and class_exists('Profiler', false)) {
// Start a new benchmark
$benchmark = Profiler::start('Kohana', __FUNCTION__);
}
if ($array or $dir === 'config' or $dir === 'i18n' or $dir === 'messages') {
// Include paths must be searched in reverse
$paths = array_reverse(Kohana::$_paths);
// Array of files that have been found
$found = [];
foreach ($paths as $dir) {
if (is_file($dir . $path)) {
// This path has a file, add it to the list
$found[] = $dir . $path;
}
}
} else {
// The file has not been found yet
$found = false;
foreach (Kohana::$_paths as $dir) {
if (is_file($dir . $path)) {
// A path has been found
$found = $dir . $path;
// Stop searching
break;
}
}
}
if (Kohana::$caching === true) {
// Add the path to the cache
Kohana::$_files[$path . ($array ? '_array' : '_path')] = $found;
// Files have been changed
Kohana::$_files_changed = true;
}
if (isset($benchmark)) {
// Stop the benchmark
Profiler::stop($benchmark);
}
return $found;
}