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


PHP Finder::ignoreUnreadableDirs方法代码示例

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


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

示例1: searchString

 /**
  * @inheritdoc
  */
 public function searchString($stringToSearch, $searchFolder)
 {
     $this->finder = $this->finderFactory->create();
     $result = new FileSearchResult($searchFolder);
     $this->finder->ignoreUnreadableDirs()->in($searchFolder);
     foreach ($this->finder->files()->contains($stringToSearch) as $file) {
         /** @var \Symfony\Component\Finder\SplFileInfo $file */
         $fileLocation = new FileLocation();
         $fileLocation->setFolder($file->getPath());
         $fileLocation->setName($file->getFilename());
         $fileLocation->setExtension($file->getExtension());
         $result->add($fileLocation);
     }
     return $result;
 }
开发者ID:zeykzso,项目名称:file-matcher,代码行数:18,代码来源:SymfonyFinder.php

示例2: installAdapters

 /**
  * Install external adapters
  * @return void
  * @throws Exception
  */
 private function installAdapters(AdaptersEvent $event)
 {
     $fs = new Filesystem();
     $finder = new Finder();
     try {
         $pluginsDir = __DIR__ . '/../../../';
         $iterator = $finder->ignoreUnreadableDirs()->files()->name('*Adapter.php')->in($pluginsDir . '*/*/Adapter/PaywallAdapters/')->in(__DIR__ . '/../Adapter/');
         foreach ($iterator as $file) {
             $classNamespace = str_replace(realpath($pluginsDir), '', substr($file->getRealPath(), 0, -4));
             $namespace = str_replace('/', '\\', $classNamespace);
             $adapterName = substr($file->getFilename(), 0, -4);
             $oneAdapter = $this->em->getRepository('Newscoop\\PaywallBundle\\Entity\\Settings')->findOneBy(array('value' => $adapterName));
             $event->registerAdapter($adapterName, array('class' => $namespace));
             if (!$oneAdapter) {
                 $adapter = new Settings();
                 $adapter->setName(str_replace("Adapter.php", "", $file->getFilename()));
                 $adapter->setValue($adapterName);
                 if ($adapterName !== 'PaypalAdapter') {
                     $adapter->setIsActive(false);
                 }
                 $this->em->persist($adapter);
             }
         }
         $this->em->flush();
     } catch (\Exception $e) {
     }
 }
开发者ID:riverans,项目名称:plugin-NewscoopPaywallBundle,代码行数:32,代码来源:AdaptersListener.php

示例3: findFiles

 /**
  * @return array
  */
 public function findFiles()
 {
     $files = array();
     $finder = new Finder();
     $iterate = false;
     $finder->ignoreUnreadableDirs();
     foreach ($this->items as $item) {
         if (!is_file($item)) {
             $finder->in($item);
             $iterate = true;
         } else {
             $files[] = realpath($item);
         }
     }
     foreach ($this->excludes as $exclude) {
         $finder->exclude($exclude);
     }
     foreach ($this->names as $name) {
         $finder->name($name);
     }
     foreach ($this->notNames as $notName) {
         $finder->notName($notName);
     }
     foreach ($this->regularExpressionsExcludes as $regularExpressionExclude) {
         $finder->notPath($regularExpressionExclude);
     }
     if ($iterate) {
         foreach ($finder as $file) {
             $files[] = $file->getRealpath();
         }
     }
     return $files;
 }
开发者ID:sakshika,项目名称:ATM,代码行数:36,代码来源:FinderFacade.php

示例4: generatedirList

 public function generatedirList()
 {
     $path = $this->container->getParameter('kernel.root_dir') . "/../";
     $finder = new Finder();
     $iterator = $finder->ignoreUnreadableDirs()->directories()->depth('< 2')->in($path);
     $dirList = array();
     foreach ($iterator as $key => $value) {
         $dirList["{$value}"] = "{$value}";
     }
     return $dirList;
 }
开发者ID:granets,项目名称:SearchBundle,代码行数:11,代码来源:SearchController.php

示例5: clear

 public function clear()
 {
     #ToDO prueba de concepto sacar a un servicio
     $manager = $this->orphanManager->get('gallery');
     $fs = new Filesystem();
     $finder = new Finder();
     if ($fs->exists($this->config['directory'] . '/' . $this->session->getId())) {
         $files = $finder->ignoreUnreadableDirs()->in($this->config['directory'] . '/' . $this->session->getId());
         $fs->remove($files);
     }
 }
开发者ID:sopinet,项目名称:uploadfiles-bundle,代码行数:11,代码来源:UploaderExtension.php

示例6: generateDirsList

 /**
  * Function that generates the directories list
  * which is used to fill the drop down options for Search Path
  *
  * @return array
  */
 public function generateDirsList()
 {
     $path = $this->get('kernel')->getRootDir();
     $finder = new Finder();
     $iterator = $finder->ignoreUnreadableDirs()->directories()->depth('< 2')->in($path);
     $dirsList = array();
     foreach ($iterator as $key => $value) {
         $dirsList["{$value}"] = "{$value}";
     }
     return $dirsList;
 }
开发者ID:emiliyank,项目名称:SimpleSearchBundle,代码行数:17,代码来源:SimpleSearchController.php

示例7: generateSecret

 protected function generateSecret($password)
 {
     $finder = new Finder();
     $root = $this->container->get('kernel')->getRootDir();
     $files = $finder->ignoreUnreadableDirs()->in($root . 'key/')->files()->name('uipubkey.pem');
     foreach ($files as $file) {
         $private_key_text = $file->getContent();
         break;
     }
     if (!$private_key_text) {
         throw new FileNotFoundException('Encryption key not found');
     }
     $rsa = new RSA();
     $rsa->loadKey($private_key_text);
     return base64_encode($rsa->encrypt($password));
 }
开发者ID:kawashita86,项目名称:gpanel,代码行数:16,代码来源:Webservice.php

示例8: tearDownAfterClass

 public static function tearDownAfterClass()
 {
     $dirs = array();
     $finder = new Finder();
     //許可がありませんDIR対応
     $finder->ignoreUnreadableDirs(true);
     $iterator = $finder->in(sys_get_temp_dir())->name('FileController*')->directories();
     foreach ($iterator as $dir) {
         $dirs[] = $dir->getPathName();
     }
     foreach ($dirs as $dir) {
         // プロセスが掴んでいるためか、確実に削除できない場合がある
         try {
             $f = new Filesystem();
             $f->remove($dir);
         } catch (\Exception $e) {
             // queit.
         }
     }
 }
开发者ID:ryo-endo,项目名称:ec-cube,代码行数:20,代码来源:FileControllerTest.php

示例9: get_files

 /**
  * Returns a Finder instance for the files that will be included in the
  * backup.
  *
  * By default we ignore unreadable files and directories as well as, common
  * version control folders / files, "Dot" files and anything matching the
  * exclude rules.
  *
  * @uses Finder
  * @return Finder The Finder iterator of all files to be included
  */
 public function get_files()
 {
     $finder = new Finder();
     $finder->followLinks(true);
     $finder->ignoreDotFiles(false);
     $finder->ignoreVCS(true);
     $finder->ignoreUnreadableDirs(true);
     // Skip unreadable files too
     $finder->filter(function (\SplFileInfo $file) {
         if (!$file->isReadable()) {
             return false;
         }
     });
     // Finder expects exclude rules to be in a regex format
     $exclude_rules = $this->excludes->get_excludes_for_regex();
     // Skips folders/files that match default exclude patterns
     foreach ($exclude_rules as $exclude) {
         $finder->notPath($exclude);
     }
     return $finder->in(Path::get_root());
 }
开发者ID:AcademicTechnologyCenter,项目名称:ATC-Quality-Tracking,代码行数:32,代码来源:class-backup-engine-file.php

示例10: installParsers

 /**
  * Install external parsers
  *
  * @return void
  *
  * @throws Exception
  */
 private function installParsers(IngestParsersEvent $event)
 {
     $fs = new Filesystem();
     $finder = new Finder();
     try {
         $pluginsDir = __DIR__ . '/../../../';
         $namespaces = array();
         $iterator = $finder->ignoreUnreadableDirs()->files()->name('*Parser.php')->notName('AbstractParser.php')->in(__DIR__ . '/../Parsers/');
         try {
             $iterator = $iterator->in($pluginsDir . '*/*/Parsers/IngestAdapters/');
         } catch (\Exception $e) {
             // Catch exception if no such directory exists
         }
         foreach ($iterator as $file) {
             $classNamespace = str_replace(realpath($pluginsDir), '', substr($file->getRealPath(), 0, -4));
             $namespace = str_replace('/', '\\', $classNamespace);
             $namespaces[] = (string) $namespace;
             $parserName = substr($file->getFilename(), 0, -4);
             $parser = $this->em->getRepository('Newscoop\\IngestPluginBundle\\Entity\\Parser')->findOneByNamespace($namespace);
             $event->registerParser($parserName, array('class' => $namespace));
             if (!$parser) {
                 $parser = new Parser();
             }
             $parser->setName($namespace::getParserName())->setDescription($namespace::getParserDescription())->setDomain($namespace::getParserDomain())->setRequiresUrl($namespace::getRequiresUrl())->setSectionHandling($namespace::getHandlesSection())->setNamespace($namespace);
             $this->em->persist($parser);
         }
         // Remove parser which we didn't find anymore
         $parsersToRemove = $this->em->createQuery('
                 DELETE FROM Newscoop\\IngestPluginBundle\\Entity\\Parser AS p
                 WHERE p.namespace NOT IN (:namespaces)
             ')->setParameter('namespaces', $namespaces)->getResult();
         $this->em->flush();
     } catch (\Exception $e) {
         throw new \Exception($e->getMessage());
     }
 }
开发者ID:thnkloud9,项目名称:plugin-IngestPluginBundle,代码行数:43,代码来源:IngestParsersListener.php

示例11: recursive_filesize_scanner

 /**
  * Recursively scans a directory to calculate the total filesize
  *
  * Locks should be set by the caller with `set_transient( 'hmbkp_directory_filesizes_running', true, HOUR_IN_SECONDS );`
  *
  * @return array $directory_sizes    An array of directory paths => filesize sum of all files in directory
  */
 public function recursive_filesize_scanner()
 {
     /**
      * Raise the `memory_limit` and `max_execution time`
      *
      * Respects the WP_MAX_MEMORY_LIMIT Constant and the `admin_memory_limit`
      * filter.
      */
     @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
     @set_time_limit(0);
     // Use the cached array directory sizes if available
     $directory_sizes = $this->get_cached_filesizes();
     // If we do have it in cache then let's use it and also clear the lock
     if (is_array($directory_sizes)) {
         delete_transient('hmbkp_directory_filesizes_running');
         return $directory_sizes;
     }
     // If we don't have it cached then we'll need to re-calculate
     $finder = new Finder();
     $finder->followLinks();
     $finder->ignoreDotFiles(false);
     $finder->ignoreUnreadableDirs(true);
     $files = $finder->in(Path::get_root());
     foreach ($files as $file) {
         if ($file->isReadable()) {
             $directory_sizes[wp_normalize_path($file->getRealpath())] = $file->getSize();
         } else {
             $directory_sizes[wp_normalize_path($file->getRealpath())] = 0;
         }
     }
     file_put_contents(PATH::get_path() . '/.files', gzcompress(json_encode($directory_sizes)));
     // Remove the lock
     delete_transient('hmbkp_directory_filesizes_running');
     return $directory_sizes;
 }
开发者ID:crazyyy,项目名称:bessarabia,代码行数:42,代码来源:class-site-size.php

示例12: list_directory_by_total_filesize

 /**
  * Return the single depth list of files and subdirectories in $directory ordered by total filesize
  *
  * Will schedule background threads to recursively calculate the filesize of subdirectories.
  * The total filesize of each directory and subdirectory is cached in a transient for 1 week.
  *
  * @param string $directory The directory to scan
  *
  * @return array returns an array of files ordered by filesize
  */
 public function list_directory_by_total_filesize($directory)
 {
     $files = $files_with_no_size = $empty_files = $files_with_size = $unreadable_files = array();
     if (!is_dir($directory)) {
         return $files;
     }
     $found = array();
     if (!empty($this->files)) {
         return $this->files;
     }
     $default_excludes = $this->backup->default_excludes();
     $finder = new Finder();
     $finder->ignoreDotFiles(false);
     $finder->ignoreUnreadableDirs();
     $finder->followLinks();
     $finder->depth('== 0');
     foreach ($default_excludes as $exclude) {
         $finder->notPath($exclude);
     }
     foreach ($finder->in($directory) as $entry) {
         $files[] = $entry;
         // Get the total filesize for each file and directory
         $filesize = $this->filesize($entry);
         if ($filesize) {
             // If there is already a file with exactly the same filesize then let's keep increasing the filesize of this one until we don't have a clash
             while (array_key_exists($filesize, $files_with_size)) {
                 $filesize++;
             }
             $files_with_size[$filesize] = $entry;
         } elseif (0 === $filesize) {
             $empty_files[] = $entry;
         } else {
             $files_with_no_size[] = $entry;
         }
     }
     // Add 0 byte files / directories to the bottom
     $files = $files_with_size + array_merge($empty_files, $unreadable_files);
     // Add directories that are still calculating to the top
     if ($files_with_no_size) {
         // We have to loop as merging or concatenating the array would re-flow the keys which we don't want because the filesize is stored in the key
         foreach ($files_with_no_size as $entry) {
             array_unshift($files, $entry);
         }
     }
     return $files;
 }
开发者ID:alexanderpetrob89,项目名称:fei.edu,代码行数:56,代码来源:class-schedule.php

示例13: get_files

 /**
  * Return an array of all files in the filesystem
  *
  * @return \RecursiveIteratorIterator
  */
 public function get_files()
 {
     $found = array();
     if (!empty($this->files)) {
         return $this->files;
     }
     $finder = new Finder();
     $finder->followLinks();
     $finder->ignoreDotFiles(false);
     $finder->ignoreUnreadableDirs();
     foreach ($this->default_excludes() as $exclude) {
         $finder->notPath($exclude);
     }
     foreach ($finder->in($this->get_root()) as $entry) {
         $this->files[] = $entry;
     }
     return $this->files;
 }
开发者ID:alexanderpetrob89,项目名称:fei.edu,代码行数:23,代码来源:class-backup.php

示例14: setUmask

 /**
  * @param string $directoryPath
  * @param array $settings
  * @param string $virtualHost
  */
 protected function setUmask($directoryPath, array $settings, $virtualHost)
 {
     $fileUmask = !empty($settings[$virtualHost]['umask']['file']) ? $settings[$virtualHost]['umask']['file'] : !empty($settings['default']['umask']['file']) ? $settings['default']['umask']['file'] : 0;
     $folderUmask = !empty($settings[$virtualHost]['umask']['folder']) ? $settings[$virtualHost]['umask']['folder'] : (!empty($settings['default']['umask']['folder']) ? $settings['default']['umask']['folder'] : 0);
     if (empty($fileUmask) && empty($folderUmask)) {
         return;
     }
     $repositoryFinder = new Finder();
     $repositoryFinder->ignoreUnreadableDirs(true)->ignoreDotFiles(false)->ignoreVCS(true)->in($directoryPath);
     if (empty($fileUmask)) {
         $repositoryFinder->directories();
     } elseif (empty($folderUmask)) {
         $repositoryFinder->files();
     }
     /** @var SplFileInfo $repositoryItem */
     foreach ($repositoryFinder as $repositoryItem) {
         if (!empty($fileUmask) && $repositoryItem->isFile()) {
             chmod($repositoryItem->getPathname(), octdec($fileUmask));
         } elseif (!empty($folderUmask) && $repositoryItem->isDir()) {
             chmod($repositoryItem->getPathname(), octdec($folderUmask));
         }
     }
 }
开发者ID:ichhabrecht,项目名称:git-checker,代码行数:28,代码来源:DirectoryController.php

示例15: ignoreUnreadableDirs

 /**
  * @return Finder
  */
 public function ignoreUnreadableDirs($ignore = true)
 {
     return parent::ignoreUnreadableDirs($ignore);
 }
开发者ID:stopsopa,项目名称:utils,代码行数:7,代码来源:Finder.php


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