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


PHP Finder::directories方法代码示例

本文整理汇总了PHP中Symfony\Component\Finder\Finder::directories方法的典型用法代码示例。如果您正苦于以下问题:PHP Finder::directories方法的具体用法?PHP Finder::directories怎么用?PHP Finder::directories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Finder\Finder的用法示例。


在下文中一共展示了Finder::directories方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fire

 /**
  * fire.
  */
 public function fire()
 {
     // set_time_limit(30);
     $path = $this->argument('path');
     $name = $this->option('name');
     $type = $this->option('type');
     $maxDepth = $this->option('maxdepth');
     $delete = $this->option('delete');
     $root = $this->getLaravel()->basePath();
     $path = realpath($root . '/' . $path);
     $this->finder->in($path);
     if ($name !== null) {
         $this->finder->name($name);
     }
     switch ($type) {
         case 'd':
             $this->finder->directories();
             break;
         case 'f':
             $this->finder->files();
             break;
     }
     if ($maxDepth !== null) {
         if ($maxDepth == '0') {
             $this->line($path);
             return;
         }
         $this->finder->depth('<' . $maxDepth);
     }
     foreach ($this->finder as $file) {
         $realPath = $file->getRealpath();
         if ($delete === 'true' && $filesystem->exists($realPath) === true) {
             try {
                 if ($filesystem->isDirectory($realPath) === true) {
                     $deleted = $filesystem->deleteDirectory($realPath, true);
                 } else {
                     $deleted = $filesystem->delete($realPath);
                 }
             } catch (Exception $e) {
             }
             if ($deleted === true) {
                 $this->info('removed ' . $realPath);
             } else {
                 $this->error('removed ' . $realPath . ' fail');
             }
         } else {
             $this->line($file->getRealpath());
         }
     }
 }
开发者ID:recca0120,项目名称:laravel-terminal,代码行数:53,代码来源:Find.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->initBuild($input, $output);
     $this->zero();
     $finder = new Finder();
     $finder->directories()->in("{$this->rootDirectory}/vendor2")->depth('== 0');
     $map = array(1 => array('composer', 'ezyang', 'gregwar', 'imagine', 'incenteev', 'jdorn'), 2 => array('doctrine'), 3 => array('endroid'), 4 => array('kriswallsmith', 'monolog', 'phpoffice'), 5 => array('pimple', 'psr', 'sensio', 'sensiolabs', 'silex', 'swiftmailer', 'symfony/assetic-bundle', 'symfony/monolog-bundle', 'symfony/swiftmailer-bundle', 'twig', 'symfony/symfony/src/Symfony/Bridge', 'symfony/symfony/src/Symfony/Bundle'), 6 => array('symfony/symfony/src/Symfony/Component/Intl', 'symfony/symfony/src/Symfony/Component/HttpKernel', 'symfony/symfony/src/Symfony/Component/Security', 'symfony/symfony/src/Symfony/Component/Form'), 7 => array('symfony/symfony/src/Symfony/Component'));
     foreach ($map as $i => $dirs) {
         $this->filesystem->remove($this->distDirectory);
         $this->filesystem->mkdir($this->distDirectory);
         $this->filesystem->mkdir("{$this->distDirectory}/vendor2");
         foreach ($dirs as $dir) {
             $this->filesystem->mirror("{$this->rootDirectory}/vendor2/{$dir}", "{$this->distDirectory}/vendor2/{$dir}");
             if ($i == 7) {
                 $this->filesystem->remove("{$this->distDirectory}/vendor2/{$dir}/Intl");
                 $this->filesystem->remove("{$this->distDirectory}/vendor2/{$dir}/HttpKernel");
                 $this->filesystem->remove("{$this->distDirectory}/vendor2/{$dir}/Security");
                 $this->filesystem->remove("{$this->distDirectory}/vendor2/{$dir}/Form");
             }
         }
         chdir($this->buildDirectory);
         $command = "zip -r vendor-{$i}.zip edusoho/";
         exec($command);
     }
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:25,代码来源:BuildVendorZipCommand.php

示例3: checkDirAction

 public function checkDirAction()
 {
     $paths = array('/' => array('depth' => '<1', 'dir' => true), 'app' => array('depth' => '<1', 'dir' => true), 'src' => array(), 'plugins' => array(), 'api' => array(), 'vendor' => array('depth' => '<1', 'dir' => true), 'vendor2' => array('depth' => '<1', 'dir' => true), 'vendor_user' => array('depth' => '<1', 'dir' => true), 'web' => array('depth' => '<1', 'dir' => true));
     $errorPaths = array();
     if (PHP_OS !== 'WINNT') {
         foreach ($paths as $folder => $opts) {
             $finder = new Finder();
             if (!empty($opts['depth'])) {
                 $finder->depth($opts['depth']);
             }
             if (!empty($opts['dir'])) {
                 $finder->directories();
             }
             try {
                 $finder->in($this->container->getParameter('kernel.root_dir') . '/../' . $folder);
                 foreach ($finder as $fileInfo) {
                     $relaPath = $fileInfo->getRealPath();
                     if (!(is_writable($relaPath) && is_readable($relaPath))) {
                         $errorPaths[] = $relaPath;
                     }
                 }
             } catch (\Exception $e) {
             }
         }
     }
     return $this->render('TopxiaAdminBundle:System:Report/dir-permission.html.twig', array('errorPaths' => $errorPaths));
 }
开发者ID:fujianguo,项目名称:EduSoho,代码行数:27,代码来源:SystemController.php

示例4: reloadBundles

 /**
  * Reloads all bundles by going through all installed bundles and refilling cache file
  */
 public function reloadBundles()
 {
     $this->bundles = [];
     if ($this->coreBundlesLocation !== false) {
         $normalizedCoreBundles = HasFilesystemRepresentation::normalizePath(Yii::getAlias($this->coreBundlesLocation));
         $coreBundles = ['bundle', 'core', 'visual-builder'];
         foreach ($coreBundles as $bundle) {
             $this->loadBundle($normalizedCoreBundles . $bundle);
         }
     }
     // load third-party bundles
     $finder = new Finder();
     try {
         $finder->directories()->in(HasFilesystemRepresentation::normalizePath(Yii::getAlias($this->bundlesLocation)) . $this->bundleLocationLookup)->ignoreUnreadableDirs()->followLinks()->sortByName()->depth('== 0');
         foreach ($finder as $directory) {
             /** @var SplFileInfo $directory */
             $this->loadBundle(dirname($directory->getRealPath()));
         }
     } catch (\InvalidArgumentException $e) {
     }
     $finder = null;
     unset($finder);
     gc_collect_cycles();
     $this->updateBundlesCache();
 }
开发者ID:DevGroup-ru,项目名称:dotplant-monster,代码行数:28,代码来源:Repository.php

示例5: buildVendorDirectory

 public function buildVendorDirectory()
 {
     $this->output->writeln('build vendor2/ .');
     $this->filesystem->mkdir("{$this->distDirectory}/vendor2");
     $this->filesystem->copy("{$this->rootDirectory}/vendor/autoload.php", "{$this->distDirectory}/vendor2/autoload.php");
     $directories = array('composer', 'doctrine/annotations/lib', 'doctrine/cache/lib', 'doctrine/collections/lib', 'doctrine/common/lib/Doctrine', 'doctrine/dbal/lib/Doctrine', 'doctrine/doctrine-bundle', 'doctrine/doctrine-cache-bundle', 'doctrine/doctrine-migrations-bundle', 'doctrine/inflector/lib', 'doctrine/lexer/lib', 'doctrine/migrations/lib', 'doctrine/orm/lib', 'endroid/qrcode/src', 'endroid/qrcode/assets', 'ezyang/htmlpurifier/library', 'gregwar/captcha', 'imagine/imagine/lib', 'incenteev/composer-parameter-handler', 'jdorn/sql-formatter/lib', 'kriswallsmith/assetic/src', 'monolog/monolog/src', 'phpoffice/phpexcel/Classes', 'pimple/pimple/lib', 'psr/log/Psr', 'sensio/distribution-bundle', 'sensio/framework-extra-bundle', 'sensio/generator-bundle', 'sensiolabs/security-checker', 'silex/silex/src', 'swiftmailer/swiftmailer/lib', 'symfony/assetic-bundle', 'symfony/monolog-bundle', 'symfony/swiftmailer-bundle', 'symfony/symfony/src', 'twig/extensions/lib', 'twig/twig/lib');
     foreach ($directories as $dir) {
         $this->filesystem->mirror("{$this->rootDirectory}/vendor/{$dir}", "{$this->distDirectory}/vendor2/{$dir}");
     }
     $this->filesystem->remove("{$this->distDirectory}/vendor2/composer/installed.json");
     $finder = new Finder();
     $finder->directories()->in("{$this->distDirectory}/vendor2");
     $toDeletes = array();
     foreach ($finder as $dir) {
         if ($dir->getFilename() == 'Tests') {
             $toDeletes[] = $dir->getRealpath();
         }
     }
     $this->filesystem->remove($toDeletes);
     $remainFiles = array('composer/LICENSE', 'doctrine/annotations/LICENSE', 'doctrine/cache/LICENSE', 'doctrine/collections/LICENSE', 'doctrine/common/LICENSE', 'doctrine/dbal/LICENSE', 'doctrine/doctrine-bundle/LICENSE', 'doctrine/inflector/LICENSE', 'doctrine/lexer/LICENSE', 'doctrine/migrations/LICENSE', 'doctrine/orm/LICENSE', 'endroid/qrcode/LICENSE', 'ezyang/htmlpurifier/LICENSE', 'gregwar/captcha/LICENSE', 'imagine/imagine/LICENSE', 'incenteev/composer-parameter-handler/LICENSE', 'jdorn/sql-formatter/LICENSE.txt', 'kriswallsmith/assetic/LICENSE', 'monolog/monolog/LICENSE', 'phpoffice/phpexcel/license.md', 'pimple/pimple/LICENSE', 'psr/log/LICENSE', 'sensiolabs/security-checker/LICENSE', 'silex/silex/LICENSE', 'swiftmailer/swiftmailer/LICENSE', 'symfony/assetic-bundle/LICENSE', 'symfony/symfony/LICENSE');
     foreach ($remainFiles as $file) {
         // $path = "{$this->rootDirectory}/vendor/{$file}";
         // if (!file_exists($path)) {
         // 	echo $path . "\n";
         // }
         $this->filesystem->copy("{$this->rootDirectory}/vendor/{$file}", "{$this->distDirectory}/vendor2/{$file}");
     }
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:28,代码来源:BuildVendorCommand.php

示例6: simpleAction

 private function simpleAction($action = 'renew', $time)
 {
     if ($this->checkLetsEncrypt()) {
         $check = new domainCheck();
         $finder = new Finder();
         $certCheck = new certsCheck();
         $le = new letsEncrypt($this->config);
         $counter = 0;
         $finder->directories()->in($this->config['system']['le-domains']);
         foreach ($finder as $file) {
             if ($action == 'renew') {
                 if ($certCheck->isCertExpire($file->getRealpath(), $time)) {
                     if ($check->isSubdomain($file->getRelativePathname())) {
                         $le->renewSubDomain($file->getRelativePathname());
                     } else {
                         $le->renewDomain($file->getRelativePathname());
                     }
                     $counter++;
                 }
             } elseif ($action == "revoke") {
                 $le->revokeDomain($file->getRelativePathname());
                 $counter++;
             }
         }
         return $counter;
     }
 }
开发者ID:heximcz,项目名称:letsencrypt-watchdog,代码行数:27,代码来源:WatchdogSimple.php

示例7: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var AlbumRepository $repo */
     $repo = $this->getContainer()->get('doctrine')->getRepository('RodgerGalleryBundle:Album');
     $webroot = $this->getContainer()->getParameter('web_root');
     $result = array();
     foreach ($repo->findAll() as $album) {
         /** @var Album $album */
         $output->writeln(sprintf("<info>[%s]</info>\t%s => %s", $album->getName(), $album->getSlug(), $album->getId()));
         $finder = new Finder();
         foreach ($finder->directories()->name($album->getSlug())->in($webroot) as $dir) {
             $output->writeln($dir->getRealpath());
             $this->addResult($album, $dir);
         }
         $finder = new Finder();
         foreach ($finder->directories()->name($album->getSlug())->in($this->getContainer()->getParameter('kernel.root_dir') . '/../uploads') as $dir) {
             $output->writeln($dir->getRealpath());
             $this->addResult($album, $dir);
         }
     }
     foreach ($this->result as $arr) {
         $output->writeln(sprintf("<info>%s => %s</info>", $arr['old'], $arr['new']));
         exec(sprintf("mv %s %s", $arr['old'], $arr['new']));
     }
 }
开发者ID:rodgermd,项目名称:mura-show.com,代码行数:25,代码来源:RenameFoldersCommand.php

示例8: boot

 public function boot()
 {
     if (true === $this->booted) {
         return;
     }
     $this->booted = true;
     $moduleConfigCacheFile = $this->getParameter('kernel.root_dir') . '/cache/' . $this->environment . '/modules_config.php';
     if (file_exists($moduleConfigCacheFile)) {
         $this->_moduleConfig = (include $moduleConfigCacheFile);
     } else {
         $finder = new Finder();
         $finder->directories()->depth('== 0');
         foreach ($this->_moduleDirectories as $dir) {
             if (glob($dir . '/*/Service', GLOB_ONLYDIR)) {
                 $finder->in($dir . '/*/Service');
             }
         }
         foreach ($finder as $dir) {
             $filepath = $dir->getRealPath() . '/module_config.php';
             if (file_exists($filepath)) {
                 $this->_moduleConfig = array_merge_recursive($this->_moduleConfig, include $filepath);
             }
         }
         if (!$this->debug) {
             $cache = "<?php \nreturn " . var_export($this->_moduleConfig, true) . ';';
             file_put_contents($moduleConfigCacheFile, $cache);
         }
     }
     $subscribers = empty($this->_moduleConfig['event_subscriber']) ? array() : $this->_moduleConfig['event_subscriber'];
     foreach ($subscribers as $subscriber) {
         $this->dispatcher()->addSubscriber(new $subscriber());
     }
 }
开发者ID:Loyalsoldier,项目名称:8000wei-v2,代码行数:33,代码来源:ServiceKernel.php

示例9: simpleAction

 private function simpleAction($action = 'renew')
 {
     $fs = new Filesystem();
     if (!$fs->exists($this->config['system']['le-domains'])) {
         throw new Exception("FATAL ERROR: Directory " . $this->config['system']['le-domains'] . " not exist. Is Let's Encrypt installed ?");
     }
     $check = new domainCheck();
     $finder = new Finder();
     $certCheck = new certsCheck();
     $le = new letsEncrypt($this->config);
     $counter = 0;
     $finder->directories()->in($this->config['system']['le-domains']);
     foreach ($finder as $file) {
         if ($certCheck->isCertExpire($file->getRealpath())) {
             if ($check->isSubdomain($file->getRelativePathname())) {
                 if ($action == 'renew') {
                     $le->renewSubDomain($file->getRelativePathname());
                 } elseif ($action == 'revoke') {
                     $le->revokeSubDomain($file->getRelativePathname());
                 }
             } else {
                 if ($action == 'renew') {
                     $le->renewDomain($file->getRelativePathname());
                 } elseif ($action == 'revoke') {
                     $le->revokeDomain($file->getRelativePathname());
                 }
             }
             $counter++;
         }
     }
     return $counter;
 }
开发者ID:clavier-souris,项目名称:letsencrypt-watchdog,代码行数:32,代码来源:WatchdogSimple.php

示例10: followLinks

 public static function followLinks(array $paths, $excludePatterns)
 {
     $finder = new Finder();
     $finder->directories();
     foreach ($excludePatterns as $excludePattern) {
         if (substr($excludePattern, 0, 1) == '/') {
             $excludePattern = substr($excludePattern, 1);
         }
         $excludePattern = '/' . preg_quote($excludePattern, '/') . '/';
         $excludePattern = str_replace(preg_quote('*', '/'), '.*', $excludePattern);
         $finder->notPath($excludePattern);
     }
     foreach ($paths as $p) {
         $finder->in($p);
     }
     foreach ($finder as $i) {
         if ($i->isLink()) {
             $realPath = $i->getRealPath();
             foreach ($paths as $k => $p2) {
                 if (substr($realPath, 0, strlen($p2) + 1) == $p2 . '/') {
                     continue 2;
                 }
             }
             $paths[] = $realPath;
         }
     }
     return $paths;
 }
开发者ID:koala-framework,项目名称:file-watcher,代码行数:28,代码来源:Links.php

示例11: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getHelperSet()->get('dialog');
     $rootDir = $input->getArgument('rootDir');
     $modules = $this->getModules();
     $finder = new Finder();
     $finder->directories()->in($rootDir)->filter(function (\SplFileInfo $file) use($modules) {
         return in_array($file->getFilename(), $modules['incompatibles']['modules']);
     });
     foreach ($finder as $file) {
         $errors['incompatibles'][] = $file->getRelativePathname();
     }
     $finder = new Finder();
     $finder->directories()->in($rootDir)->filter(function (\SplFileInfo $file) use($modules) {
         return in_array($file->getFilename(), $modules['warnings']['modules']);
     });
     foreach ($finder as $file) {
         $errors['warnings'][] = $file->getRelativePathname();
     }
     foreach ($errors as $type => $error) {
         $output->writeln('<info>' . $type . '</info>');
         foreach ($error as $a) {
             $output->writeln('<error>' . $a . '</error>');
         }
     }
 }
开发者ID:bacardi55,项目名称:ac-incompatibles-checks,代码行数:26,代码来源:FindCommand.php

示例12: patchOldVersions

 /**
  * Try to patch all older versions, in Patch\Version_X_Y_Z dirs
  *
  * @param BundleVersion $bundleVersion
  * @return Version
  */
 protected function patchOldVersions(BundleVersion $bundleVersion)
 {
     $reflection = new \ReflectionClass(get_called_class());
     $fileInfos = new \SplFileInfo($reflection->getFileName());
     $patchPath = $fileInfos->getPath() . DIRECTORY_SEPARATOR . 'Patch';
     // directory doesn't exists, no patch to call
     if (is_dir($patchPath) === false) {
         return $bundleVersion->getInstalledVersion();
     }
     // dirs like Update\Version_X_Y_Z
     $finderVersions = new Finder();
     $finderVersions->directories()->in($patchPath)->name('Version_*')->sortByName();
     $dirsVersions = array();
     foreach ($finderVersions as $dir) {
         $dirsVersions[] = str_replace('_', '.', substr($dir->getFilename(), 8));
     }
     usort($dirsVersions, array($this, 'compareDirVersion'));
     // now that we have dirs in right order, let's find patch files
     $return = $bundleVersion->getInstalledVersion();
     foreach ($dirsVersions as $dir) {
         $files = $this->findPatchsFiles($patchPath . DIRECTORY_SEPARATOR . 'Version_' . str_replace('.', '_', $dir));
         foreach ($files as $file) {
             $className = $reflection->getNamespaceName() . '\\Patch\\Version_' . str_replace('.', '_', $dir) . '\\' . $file->getBasename('.' . $file->getExtension());
             $this->callUpdate($className, $bundleVersion);
         }
         $return = new Version($dir);
     }
     return $return;
 }
开发者ID:kujaff,项目名称:versionsbundle,代码行数:35,代码来源:UpdateByPatchs.php

示例13: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $destroy_prs = array();
     $pull_request = $this->getConfigParameter('pull_request');
     $pr_directories = $this->getConfigParameter('pr_directories');
     // Get deployed PR's based on directories in $pr_directories and compare
     // that to the PR's open on GitHub.
     if ($input->getOption('closed')) {
         $deployed_prs = array();
         $finder = new Finder();
         // @TODO need to ensure that prefix is alphanumeric ONLY.
         $pattern = '/^' . $pull_request['prefix'] . '\\-([0-9]+)/';
         $iterator = $finder->directories()->name($pattern)->depth(0)->in($pr_directories);
         foreach ($iterator as $directory) {
             preg_match($pattern, $directory->getFilename(), $matches);
             $deployed_prs[] = $matches[1];
         }
         if (!empty($deployed_prs)) {
             $github = $this->getGithub();
             $open_prs = array();
             $paginator = new Github\ResultPager($github);
             $prs = $paginator->fetchAll($github->api('pr'), 'all', array($this->getConfigParameter('organization'), $this->getConfigParameter('repository'), array('state' => 'open')));
             foreach ($prs as $pr) {
                 $open_prs[] = $pr['number'];
             }
             // PR's to destroy are deployed PR's that are not open.
             $destroy_prs = array_diff($deployed_prs, $open_prs);
         }
     } else {
         $pr_number = $input->getArgument('pull-request');
         if (!is_numeric($pr_number)) {
             throw new \Exception("PR must be a number.");
         }
         $destroy_prs[] = $pr_number;
     }
     if (!empty($destroy_prs)) {
         $fs = new Filesystem();
         $site_dir = $input->getOption('site-dir');
         foreach ($destroy_prs as $destroy_pr) {
             // @TODO get this path from a central place.
             $pr_path = rtrim($pr_directories, '/') . "/{$pull_request['prefix']}-{$destroy_pr}.{$pull_request['domain']}";
             if ($fs->exists($pr_path)) {
                 // Drop the database.
                 // @TODO set/get database name in central place, and use in DrupalSettings.
                 $database = $pull_request['prefix'] . '_' . $destroy_pr;
                 $process = new Process("drush sqlq 'DROP database {$database}'", $pr_path . "/docroot/sites/" . $site_dir);
                 $process->run();
                 // Remove the PR's web root.
                 $fs->remove($pr_path);
                 // @TODO destroy memcache bins.
                 $output->writeln("<info>Successfully destroyed PR #{$destroy_pr}</info>");
             }
         }
     } else {
         $output->writeln("<info>No PR's to destroy.</info>");
     }
 }
开发者ID:rabellamy,项目名称:flo,代码行数:60,代码来源:DestroyCommand.php

示例14: getModules

 /**
  * @return array Array containing all modules keys
  */
 protected function getModules()
 {
     $finder = new Finder();
     $finder->directories()->in(THEBUGGENIE_PATH . '/modules')->depth('== 0');
     foreach ($finder as $file) {
         $modules[] = $file->getRelativePathname();
     }
     return $modules;
 }
开发者ID:pkdevboxy,项目名称:thebuggenie,代码行数:12,代码来源:ExtractStrings.php

示例15: getChildren

 public function getChildren()
 {
     $finder = new Finder();
     $finder->directories()->in($this->file_info->getPathname())->depth('== 0')->sortByName();
     $categories = array();
     foreach ($finder as $dir) {
         $categories[] = new Category($dir, $this->content_provider);
     }
     return $categories;
 }
开发者ID:Windy619,项目名称:Bloghoven,代码行数:10,代码来源:Category.php


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