本文整理汇总了PHP中Dir::read方法的典型用法代码示例。如果您正苦于以下问题:PHP Dir::read方法的具体用法?PHP Dir::read怎么用?PHP Dir::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dir
的用法示例。
在下文中一共展示了Dir::read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: templateNames
/**
* Return possible template names that can be used by the nodes
* for rendering by listing all files from the node view directory
*
* @return array(string)
*/
public function templateNames()
{
$templateNames = new IndexedArray();
// get correct template directory from appcontroller’s theme
$r = get_class_vars('AppController');
if (empty($r['theme'])) {
$templateDir = VIEW_DIR . 'node/';
} else {
$templateDir = VIEW_DIR . 'theme/' . $r['theme'] . '/node/';
}
// list files
$dir = new Dir($templateDir);
foreach ($dir->read('@\\.php$@') as $file) {
if (!$file->isFile()) {
continue;
}
// ignore directories
if (in_array($file->basename(false), array())) {
continue;
}
// ignore files?
$templateNames[$file->basename(false)] = $file->basename(false);
}
return $templateNames->toArray();
}
示例2: bundles
/**
* Generate a list of bundle language files
*
* @param array $from
* @param array $to
* @return array
*/
protected static function bundles($from, $to)
{
// First start with the application dir
$from_files = Dir::bundles($from);
$files = array();
foreach ($from_files as $bundle) {
$bundle_files = Dir::read($bundle['path'] . $from);
foreach ($bundle_files as $key => $file) {
$from_array = (require $file);
$to_file = str_replace($from, $to, $file);
$to_array = is_file($to_file) ? require $to_file : array();
$files['all'][] = array('location' => $bundle['name'], 'name' => str_replace(path('bundle'), '', basename($to_file, '.php')));
// Do all our keys match?
if (static::keys($from_array, $to_array)) {
$files['missing'][] = array('location' => $bundle['name'], 'name' => str_replace(path('bundle'), '', basename($to_file, '.php')));
} else {
// If all our keys match we need check our values aren't empty.
if (static::values($to_array)) {
$files['missing'][] = array('location' => $bundle['name'], 'name' => str_replace(path('bundle'), '', basename($to_file, '.php')));
}
}
}
}
return $files;
}