当前位置: 首页>>代码示例>>PHP>>正文


PHP Filesystem\Folder类代码示例

本文整理汇总了PHP中Grav\Common\Filesystem\Folder的典型用法代码示例。如果您正苦于以下问题:PHP Folder类的具体用法?PHP Folder怎么用?PHP Folder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Folder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
     }
 }
开发者ID:clee03,项目名称:metal,代码行数:7,代码来源:Types.php

示例2: backup

 public static function backup($destination = null, callable $messager = null)
 {
     if (!$destination) {
         $destination = self::getGrav()['locator']->findResource('backup://', true);
         if (!$destination) {
             throw new \RuntimeException('The backup folder is missing.');
         }
         Folder::mkdir($destination);
     }
     $name = self::getGrav()['config']->get('site.title', basename(GRAV_ROOT));
     $inflector = new Inflector();
     if (is_dir($destination)) {
         $date = date('YmdHis', time());
         $filename = trim($inflector->hyphenize($name), '-') . '-' . $date . '.zip';
         $destination = rtrim($destination, DS) . DS . $filename;
     }
     $messager && $messager(['type' => 'message', 'level' => 'info', 'message' => 'Creating new Backup "' . $destination . '"']);
     $messager && $messager(['type' => 'message', 'level' => 'info', 'message' => '']);
     $zip = new \ZipArchive();
     $zip->open($destination, \ZipArchive::CREATE);
     $max_execution_time = ini_set('max_execution_time', 600);
     static::folderToZip(GRAV_ROOT, $zip, strlen(rtrim(GRAV_ROOT, DS) . DS), $messager);
     $messager && $messager(['type' => 'progress', 'percentage' => false, 'complete' => true]);
     $messager && $messager(['type' => 'message', 'level' => 'info', 'message' => '']);
     $messager && $messager(['type' => 'message', 'level' => 'info', 'message' => 'Saving and compressing archive...']);
     $zip->close();
     if ($max_execution_time !== false) {
         ini_set('max_execution_time', $max_execution_time);
     }
     return $destination;
 }
开发者ID:khanduras,项目名称:grav,代码行数:31,代码来源:ZipBackup.php

示例3: 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);
         }
     }
 }
开发者ID:qbi,项目名称:datenknoten.me,代码行数:12,代码来源:Types.php

示例4: cleanPaths

 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 private function cleanPaths(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('');
     $output->writeln('<magenta>Clearing cache</magenta>');
     $output->writeln('');
     $user_config = USER_DIR . 'config/system.yaml';
     $anything = false;
     if ($input->getOption('all')) {
         $remove_paths = $this->all_remove;
     } elseif ($input->getOption('assets-only')) {
         $remove_paths = $this->assets_remove;
     } elseif ($input->getOption('images-only')) {
         $remove_paths = $this->images_remove;
     } elseif ($input->getOption('cache-only')) {
         $remove_paths = $this->cache_remove;
     } else {
         $remove_paths = $this->standard_remove;
     }
     foreach ($remove_paths as $path) {
         $files = glob(ROOT_DIR . $path . '*');
         foreach ($files as $file) {
             if (is_file($file)) {
                 if (@unlink($file)) {
                     $anything = true;
                 }
             } elseif (is_dir($file)) {
                 if (@Folder::delete($file)) {
                     $anything = true;
                 }
             }
         }
         if ($anything) {
             $output->writeln('<red>Cleared:  </red>' . $path . '*');
         }
     }
     if (file_exists($user_config)) {
         touch($user_config);
         $output->writeln('');
         $output->writeln('<red>Touched: </red>' . $user_config);
         $output->writeln('');
     }
     if (!$anything) {
         $output->writeln('<green>Nothing to clear...</green>');
         $output->writeln('');
     }
 }
开发者ID:qbi,项目名称:datenknoten.me,代码行数:50,代码来源:ClearCacheCommand.php

示例5: serve

 protected function serve()
 {
     $this->options['name'] = $this->input->getArgument('name');
     $this->name['machine'] = $this->generateMachineName($this->options['name']);
     $this->name['camel'] = $this->generateCamelName($this->options['name']);
     $path['src'] = PLUGINS_DIR . 'component-generator/' . self::COMPONENT;
     $path['dest'] = PLUGINS_DIR . $this->name['machine'];
     $path['tmp'] = CACHE_DIR . 'tmp/' . self::COMPONENT;
     $replace = array('/{{ COMPONENT }}/' => lcfirst($this->name['camel']), '/{{ COMPONENT NAME }}/' => $this->options['name'], '/{{ COMPONENT CAMEL NAME }}/' => $this->name['camel'], '/{{ COMPONENT MACHINE NAME }}/' => $this->name['machine']);
     // Copy dir to cache/temp
     Folder::copy($path['src'], $path['tmp']);
     // Recursively rewrite file names and contents of all files
     $this->rewriteRecursive($path['tmp'], array_keys($replace), array_values($replace));
     // Move dir to rest
     Folder::move($path['tmp'], $path['dest']);
     // Success message
 }
开发者ID:ellioseven,项目名称:grav-plugin-modular-component-generator,代码行数:17,代码来源:ScaffoldCommand.php

示例6: cleanPaths

 private function cleanPaths()
 {
     $this->output->writeln('');
     $this->output->writeln('<red>DELETING</red>');
     $anything = false;
     foreach ($this->paths_to_remove as $path) {
         $path = ROOT_DIR . $path;
         if (is_dir($path) && @Folder::delete($path)) {
             $anything = true;
             $this->output->writeln('<red>dir:  </red>' . $path);
         } elseif (is_file($path) && @unlink($path)) {
             $anything = true;
             $this->output->writeln('<red>file: </red>' . $path);
         }
     }
     if (!$anything) {
         $this->output->writeln('');
         $this->output->writeln('<green>Nothing to clean...</green>');
     }
 }
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:20,代码来源:CleanCommand.php

示例7: download

 private static function download($package)
 {
     $contents = Response::get($package->zipball_url, []);
     $cache_dir = self::getGrav()['locator']->findResource('cache://', true);
     $cache_dir = $cache_dir . DS . 'tmp/Grav-' . uniqid();
     Folder::mkdir($cache_dir);
     $filename = $package->slug . basename($package->zipball_url);
     file_put_contents($cache_dir . DS . $filename, $contents);
     return $cache_dir . DS . $filename;
 }
开发者ID:symac,项目名称:grav-plugin-admin,代码行数:10,代码来源:gpm.php

示例8: clearCache

 /**
  * Helper method to clear all Grav caches
  *
  * @param string $remove standard|all|assets-only|images-only|cache-only
  *
  * @return array
  */
 public static function clearCache($remove = 'standard')
 {
     $locator = Grav::instance()['locator'];
     $output = [];
     $user_config = USER_DIR . 'config/system.yaml';
     switch ($remove) {
         case 'all':
             $remove_paths = self::$all_remove;
             break;
         case 'assets-only':
             $remove_paths = self::$assets_remove;
             break;
         case 'images-only':
             $remove_paths = self::$images_remove;
             break;
         case 'cache-only':
             $remove_paths = self::$cache_remove;
             break;
         case 'tmp-only':
             $remove_paths = self::$tmp_remove;
             break;
         default:
             $remove_paths = self::$standard_remove;
     }
     foreach ($remove_paths as $stream) {
         // Convert stream to a real path
         try {
             $path = $locator->findResource($stream, true, true);
         } catch (\Exception $e) {
             // stream not found..
             continue;
         }
         $anything = false;
         $files = glob($path . '/*');
         if (is_array($files)) {
             foreach ($files as $file) {
                 if (is_file($file)) {
                     if (@unlink($file)) {
                         $anything = true;
                     }
                 } elseif (is_dir($file)) {
                     if (Folder::delete($file)) {
                         $anything = true;
                     }
                 }
             }
         }
         if ($anything) {
             $output[] = '<red>Cleared:  </red>' . $path . '/*';
         }
     }
     $output[] = '';
     if (($remove == 'all' || $remove == 'standard') && file_exists($user_config)) {
         touch($user_config);
         $output[] = '<red>Touched: </red>' . $user_config;
         $output[] = '';
     }
     return $output;
 }
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:66,代码来源:Cache.php

示例9: buildPages

 /**
  * Builds pages.
  *
  * @internal
  */
 protected function buildPages()
 {
     $this->sort = array();
     /** @var Config $config */
     $config = $this->grav['config'];
     /** @var UniformResourceLocator $locator */
     $locator = $this->grav['locator'];
     $pagesDir = $locator->findResource('page://');
     if ($config->get('system.cache.enabled')) {
         /** @var Cache $cache */
         $cache = $this->grav['cache'];
         /** @var Taxonomy $taxonomy */
         $taxonomy = $this->grav['taxonomy'];
         // how should we check for last modified? Default is by file
         switch (strtolower($config->get('system.cache.check.method', 'file'))) {
             case 'none':
             case 'off':
                 $last_modified = 0;
                 break;
             case 'folder':
                 $last_modified = Folder::lastModifiedFolder($pagesDir);
                 break;
             default:
                 $last_modified = Folder::lastModifiedFile($pagesDir);
         }
         $page_cache_id = md5(USER_DIR . $last_modified . $config->checksum());
         list($this->instances, $this->routes, $this->children, $taxonomy_map, $this->sort) = $cache->fetch($page_cache_id);
         if (!$this->instances) {
             $this->grav['debugger']->addMessage('Page cache missed, rebuilding pages..');
             $this->recurse($pagesDir);
             $this->buildRoutes();
             // save pages, routes, taxonomy, and sort to cache
             $cache->save($page_cache_id, array($this->instances, $this->routes, $this->children, $taxonomy->taxonomy(), $this->sort));
         } else {
             // If pages was found in cache, set the taxonomy
             $this->grav['debugger']->addMessage('Page cache hit.');
             $taxonomy->taxonomy($taxonomy_map);
         }
     } else {
         $this->recurse($pagesDir);
         $this->buildRoutes();
     }
 }
开发者ID:alexslack,项目名称:faith-game,代码行数:48,代码来源:Pages.php

示例10: installPackage

 /**
  * Install a package
  *
  * @param Package $package
  * @param bool    $is_update True if it's an update. False if it's an install
  *
  * @return bool
  */
 private function installPackage($package, $is_update = false)
 {
     $type = $package->package_type;
     Installer::install($this->file, $this->destination, ['install_path' => $package->install_path, 'theme' => $type == 'themes', 'is_update' => $is_update]);
     $error_code = Installer::lastErrorCode();
     Folder::delete($this->tmp);
     if ($error_code) {
         $this->output->write("\r");
         // extra white spaces to clear out the buffer properly
         $this->output->writeln("  |- Installing package...    <red>error</red>                             ");
         $this->output->writeln("  |  '- " . Installer::lastErrorMsg());
         return false;
     }
     $message = Installer::getMessage();
     if ($message) {
         $this->output->write("\r");
         // extra white spaces to clear out the buffer properly
         $this->output->writeln("  |- " . $message);
     }
     $this->output->write("\r");
     // extra white spaces to clear out the buffer properly
     $this->output->writeln("  |- Installing package...    <green>ok</green>                             ");
     return true;
 }
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:32,代码来源:InstallCommand.php

示例11: pages

 /**
  *
  */
 private function pages()
 {
     $this->output->writeln('');
     $this->output->writeln('<comment>Pages Initializing</comment>');
     // get pages files and initialize if no pages exist
     $pages_dir = $this->destination . '/user/pages';
     $pages_files = array_diff(scandir($pages_dir), array('..', '.'));
     if (count($pages_files) == 0) {
         $destination = $this->source . '/user/pages';
         Folder::rcopy($destination, $pages_dir);
         $this->output->writeln('    <cyan>' . $destination . '</cyan> <comment>-></comment> Created');
     }
 }
开发者ID:emac,项目名称:emacoo.cn,代码行数:16,代码来源:SandboxCommand.php

示例12: 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];
 }
开发者ID:gabykode,项目名称:tf,代码行数:21,代码来源:ConfigFinder.php

示例13: isset

<?php

/**
 * Multisite setup for sub-directories or path based
 * URLs for subsites.
 *
 * DO NOT EDIT UNLESS YOU KNOW WHAT YOU ARE DOING!
 */
use Grav\Common\Filesystem\Folder;
// Get relative path from Grav root.
$path = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : Folder::getRelativePath($_SERVER['REQUEST_URI'], ROOT_DIR);
// Extract name of subsite from path
$name = Folder::shift($path);
$folder = "sites/{$name}";
$prefix = "/{$name}";
if (!$name || !is_dir(ROOT_DIR . "user/{$folder}")) {
    return [];
}
// Prefix all pages with the name of the subsite
$container['pages']->base($prefix);
return ['environment' => $name, 'streams' => ['schemes' => ['user' => ['type' => 'ReadOnlyStream', 'prefixes' => ['' => ["user/{$folder}"]]]]]];
开发者ID:madanyu,项目名称:learn,代码行数:21,代码来源:setup.php

示例14: selfupgrade

 public static function selfupgrade()
 {
     $upgrader = new Upgrader();
     if (!Installer::isGravInstance(GRAV_ROOT)) {
         return false;
     }
     if (is_link(GRAV_ROOT . DS . 'index.php')) {
         Installer::setError(Installer::IS_LINK);
         return false;
     }
     $update = $upgrader->getAssets()['grav-update'];
     $tmp = CACHE_DIR . 'tmp/Grav-' . uniqid();
     $file = self::_downloadSelfupgrade($update, $tmp);
     Installer::install($file, GRAV_ROOT, ['sophisticated' => true, 'overwrite' => true, 'ignore_symlinks' => true]);
     $errorCode = Installer::lastErrorCode();
     Folder::delete($tmp);
     if ($errorCode & (Installer::ZIP_OPEN_ERROR | Installer::ZIP_EXTRACT_ERROR)) {
         return false;
     }
     return true;
 }
开发者ID:nicolasdanelon,项目名称:grav-plugin-admin,代码行数:21,代码来源:gpm.php

示例15: getFilesOrderedByModifiedDate

 private function getFilesOrderedByModifiedDate($path = '')
 {
     $files = [];
     if (!$path) {
         $path = DATA_DIR . 'comments';
     }
     if (!file_exists($path)) {
         Folder::mkdir($path);
     }
     $dirItr = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS);
     $filterItr = new RecursiveFolderFilterIterator($dirItr);
     $itr = new \RecursiveIteratorIterator($filterItr, \RecursiveIteratorIterator::SELF_FIRST);
     $itrItr = new \RecursiveIteratorIterator($dirItr, \RecursiveIteratorIterator::SELF_FIRST);
     $filesItr = new \RegexIterator($itrItr, '/^.+\\.yaml$/i');
     // Collect files if modified in the last 7 days
     foreach ($filesItr as $filepath => $file) {
         $modifiedDate = $file->getMTime();
         $sevenDaysAgo = time() - 7 * 24 * 60 * 60;
         if ($modifiedDate < $sevenDaysAgo) {
             continue;
         }
         $files[] = (object) array("modifiedDate" => $modifiedDate, "fileName" => $file->getFilename(), "filePath" => $filepath, "data" => Yaml::parse(file_get_contents($filepath)));
     }
     // Traverse folders and recurse
     foreach ($itr as $file) {
         if ($file->isDir()) {
             $this->getFilesOrderedByModifiedDate($file->getPath() . '/' . $file->getFilename());
         }
     }
     // Order files by last modified date
     usort($files, function ($a, $b) {
         return !($a->modifiedDate > $b->modifiedDate);
     });
     return $files;
 }
开发者ID:JETZero3,项目名称:Drifters-with-Pencils,代码行数:35,代码来源:comments.php


注:本文中的Grav\Common\Filesystem\Folder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。