本文整理汇总了PHP中Grav\Common\Filesystem\Folder::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::all方法的具体用法?PHP Folder::all怎么用?PHP Folder::all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grav\Common\Filesystem\Folder
的用法示例。
在下文中一共展示了Folder::all方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findBlueprints
private function findBlueprints($paths)
{
$options = ['compare' => 'Filename', 'pattern' => '|\\.yaml$|', 'filters' => ['key' => '|\\.yaml$|'], 'key' => 'SubPathName', 'value' => 'PathName'];
foreach ((array) $paths as $path) {
return Folder::all($path, $options);
}
}
示例2: scanTemplates
public function scanTemplates($path)
{
$options = ['compare' => 'Filename', 'pattern' => '|\\.html\\.twig$|', 'filters' => ['value' => '|\\.html\\.twig$|'], 'value' => 'Filename', 'recursive' => false];
foreach (Folder::all($path, $options) as $type) {
$this->register($type);
}
if (file_exists($path . 'modular/')) {
foreach (Folder::all($path . 'modular/', $options) as $type) {
$this->register('modular/' . $type);
}
}
}
示例3: detectConfig
/**
* Detects all plugins with a configuration file and returns last modification time.
*
* @param string $lookup Location to look up from.
* @param bool $blueprints
* @return array
* @internal
*/
protected function detectConfig($lookup = SYSTEM_DIR, $blueprints = false)
{
$location = $blueprints ? 'blueprintFiles' : 'configFiles';
$path = trim(Folder::getRelativePath($lookup), '/');
if (isset($this->{$location}[$path])) {
return [$path => $this->{$location}[$path]];
}
if (is_dir($lookup)) {
// Find all system and user configuration files.
$options = ['compare' => 'Filename', 'pattern' => '|\\.yaml$|', 'filters' => ['key' => '|\\.yaml$|', 'value' => function (\RecursiveDirectoryIterator $file) use($path) {
return ['file' => "{$path}/{$file->getSubPathname()}", 'modified' => $file->getMTime()];
}], 'key' => 'SubPathname'];
$list = Folder::all($lookup, $options);
} else {
$list = [];
}
$this->{$location}[$path] = $list;
return [$path => $list];
}
示例4: getNextOrderInFolder
/**
* Get the next available ordering number in a folder
*
* @param $path
*
* @return string the correct order string to prepend
*/
private function getNextOrderInFolder($path)
{
$files = Folder::all($path, ['recursive' => false]);
$highestOrder = 0;
foreach ($files as $file) {
preg_match(PAGE_ORDER_PREFIX_REGEX, $file, $order);
if (isset($order[0])) {
$theOrder = intval(trim($order[0], '.'));
} else {
$theOrder = 0;
}
if ($theOrder >= $highestOrder) {
$highestOrder = $theOrder;
}
}
$orderOfNewFolder = $highestOrder + 1;
if ($orderOfNewFolder < 10) {
$orderOfNewFolder = '0' . $orderOfNewFolder;
}
return $orderOfNewFolder;
}
示例5: detectAll
/**
* Detects all plugins with a configuration file and returns them with last modification time.
*
* @param string $folder Location to look up from.
* @param string $pattern Pattern to match the file. Pattern will also be removed from the key.
* @param int $levels Maximum number of recursive directories.
* @return array
* @internal
*/
protected function detectAll($folder, $pattern, $levels)
{
$path = trim(Folder::getRelativePath($folder), '/');
if (is_dir($folder)) {
// Find all system and user configuration files.
$options = ['levels' => $levels, 'compare' => 'Filename', 'pattern' => $pattern, 'filters' => ['pre-key' => $this->base, 'key' => $pattern, 'value' => function (\RecursiveDirectoryIterator $file) use($path) {
return ["{$path}/{$file->getSubPathname()}" => $file->getMTime()];
}], 'key' => 'SubPathname'];
$list = Folder::all($folder, $options);
ksort($list);
} else {
$list = [];
}
return $list;
}
示例6: build
/**
* Build a list of configuration files with their timestamps. Used for loading settings and caching them.
*
* @return array
* @internal
*/
protected function build()
{
// Find all plugins with default configuration options.
$plugins = array();
$iterator = new \DirectoryIterator(PLUGINS_DIR);
/** @var \DirectoryIterator $plugin */
foreach ($iterator as $plugin) {
$name = $plugin->getBasename();
$file = $plugin->getPathname() . DS . $name . YAML_EXT;
if (!is_file($file)) {
continue;
}
$modified = filemtime($file);
$plugins["plugins/{$name}"] = $modified;
}
// Find all system and user configuration files.
$options = array('compare' => 'Filename', 'pattern' => '|\\.yaml$|', 'filters' => array('key' => '|\\.yaml$|'), 'key' => 'SubPathname', 'value' => 'MTime');
$system = Folder::all(SYSTEM_DIR . 'config', $options);
$user = Folder::all(USER_DIR . 'config', $options);
return array('system' => $system, 'plugins' => $plugins, 'user' => $user);
}
示例7: detectRecursive
/**
* Detects all plugins with a configuration file and returns them with last modification time.
*
* @param string $folder Location to look up from.
* @return array
* @internal
*/
protected function detectRecursive($folder)
{
$path = trim(Folder::getRelativePath($folder), '/');
if (is_dir($folder)) {
// Find all system and user configuration files.
$options = ['compare' => 'Filename', 'pattern' => '|\\.yaml$|', 'filters' => ['key' => '|\\.yaml$|', 'value' => function (\RecursiveDirectoryIterator $file) use($path) {
return ['file' => "{$path}/{$file->getSubPathname()}", 'modified' => $file->getMTime()];
}], 'key' => 'SubPathname'];
$list = Folder::all($folder, $options);
} else {
$list = [];
}
return [$path => $list];
}
示例8: findBlueprints
private function findBlueprints($path)
{
$options = [
'compare' => 'Filename',
'pattern' => '|\.yaml$|',
'filters' => [
'key' => '|\.yaml$|'
],
'key' => 'SubPathName',
'value' => 'PathName',
];
return Folder::all($path, $options);
}
示例9: findBlueprints
private function findBlueprints($uri)
{
$options = ['compare' => 'Filename', 'pattern' => '|\\.yaml$|', 'filters' => ['key' => '|\\.yaml$|'], 'key' => 'SubPathName', 'value' => 'PathName'];
/** @var UniformResourceLocator $locator */
$locator = Grav::instance()['locator'];
if ($locator->isStream($uri)) {
$options['value'] = 'Url';
}
$list = Folder::all($uri, $options);
return $list;
}
示例10: taskSaveNewFolder
/**
* Handles creating an empty page folder (without markdown file)
*
* @return bool True if the action was performed.
*/
public function taskSaveNewFolder()
{
if (!$this->authorizeTask('save', $this->dataPermissions())) {
return;
}
$data = $this->post;
if ($data['route'] == '/') {
$path = $this->grav['locator']->findResource('page://');
} else {
$path = $page = $this->grav['page']->find($data['route'])->path();
}
$files = Folder::all($path, ['recursive' => false]);
$highestOrder = 0;
foreach ($files as $file) {
preg_match(PAGE_ORDER_PREFIX_REGEX, $file, $order);
if (isset($order[0])) {
$theOrder = intval(trim($order[0], '.'));
} else {
$theOrder = 0;
}
if ($theOrder >= $highestOrder) {
$highestOrder = $theOrder;
}
}
$orderOfNewFolder = $highestOrder + 1;
if ($orderOfNewFolder < 10) {
$orderOfNewFolder = '0' . $orderOfNewFolder;
}
Folder::mkdir($path . '/' . $orderOfNewFolder . '.' . $data['folder']);
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.SUCCESSFULLY_SAVED'), 'info');
$multilang = $this->isMultilang();
$admin_route = $this->grav['config']->get('plugins.admin.route');
$redirect_url = '/' . ($multilang ? $this->grav['session']->admin_lang : '') . $admin_route . '/' . $this->view;
$this->setRedirect($redirect_url);
return true;
}