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


PHP Finder::find方法代码示例

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


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

示例1: zipFiles

 /**
  * Zip files
  *
  * @param string $targetDir Target dir path
  * @param array  $files     Files to zip
  *
  * @throws \Exception
  */
 private function zipFiles($targetDir, $files)
 {
     $zip = new \ZipArchive();
     $zipName = pathinfo($files[0], PATHINFO_FILENAME);
     $zipPath = FileSystem::getUniquePath($targetDir . DIRECTORY_SEPARATOR . $zipName . ".zip");
     if ($zip->open($zipPath, \ZipArchive::CREATE)) {
         foreach ($files as $file) {
             $path = $targetDir . DIRECTORY_SEPARATOR . $file;
             if (is_dir($path)) {
                 $zip->addEmptyDir($file);
                 foreach (Finder::find("*")->from($path) as $item) {
                     $name = $file . DIRECTORY_SEPARATOR . substr_replace($item->getPathname(), "", 0, strlen($path) + 1);
                     if ($item->isDir()) {
                         $zip->addEmptyDir($name);
                     } else {
                         $zip->addFile($item->getRealPath(), $name);
                     }
                 }
             } else {
                 $zip->addFile($path, $file);
             }
         }
         $zip->close();
     } else {
         throw new \Exception("Can not create ZIP archive '{$zipPath}' from '{$targetDir}'.");
     }
 }
开发者ID:ixtrum,项目名称:file-manager-plugins,代码行数:35,代码来源:Zip.php

示例2: Finder

<?php

include "functions.php";
//Récupérer le paramétre de l'identifiant passé dans l'URL de la page
$id = $_GET["film"];
//Trouver le bon film
$finder = new Finder($data);
$film = $finder->find($id);
?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title><?php 
echo "MVA - " . $film->title;
?>
</title>
        <link href="css/bootstrap.min.css" rel="stylesheet" />
        <script src="js/jquery-2.2.0.min.js"></script>
        <script src="js/bootstrap.min.js"></script>
    </head>
    <body>
       <nav class="navbar navbar-default" role="navigation">
           <div class="container">
                <div class="collapse navbar-collapse">
                    <ul class="nav navbar-nav">
                       <li><a href="/">Films</a></li>
                       <li><a href="#">A Propos</a></li>
                       <li><a href="#">Contact</a></li>
                    </ul>
开发者ID:lasticshow,项目名称:filmmva6,代码行数:31,代码来源:detail.php

示例3: clean

 /**
  * Removes items from the cache by conditions & garbage collector.
  * @param  array  conditions
  * @return void
  */
 public function clean(array $conds)
 {
     $all = !empty($conds[Cache::ALL]);
     $collector = empty($conds);
     // cleaning using file iterator
     if ($all || $collector) {
         $now = time();
         foreach (Finder::find('_*')->from($this->dir)->childFirst() as $entry) {
             $path = (string) $entry;
             if ($entry->isDir()) {
                 // collector: remove empty dirs
                 @rmdir($path);
                 // @ - removing dirs is not necessary
                 continue;
             }
             if ($all) {
                 $this->delete($path);
             } else {
                 // collector
                 $meta = $this->readMetaAndLock($path, LOCK_SH);
                 if (!$meta) {
                     continue;
                 }
                 if (!empty($meta[self::META_DELTA]) && filemtime($meta[self::FILE]) + $meta[self::META_DELTA] < $now || !empty($meta[self::META_EXPIRE]) && $meta[self::META_EXPIRE] < $now) {
                     $this->delete($path, $meta[self::HANDLE]);
                     continue;
                 }
                 flock($meta[self::HANDLE], LOCK_UN);
                 fclose($meta[self::HANDLE]);
             }
         }
         if ($this->journal) {
             $this->journal->clean($conds);
         }
         return;
     }
     // cleaning using journal
     if ($this->journal) {
         foreach ($this->journal->clean($conds) as $file) {
             $this->delete($file);
         }
     }
 }
开发者ID:riskatlas,项目名称:micka,代码行数:48,代码来源:FileStorage.php

示例4: includeDir

 public function includeDir($path, $types, $recursive, $indent)
 {
     if (!file_exists($path) || !is_dir($path)) {
         throw new \LogicException("{$path} does not exist or is not a directory");
     }
     $files = Finder::find($path, $types, $recursive);
     $contents = '';
     foreach ($files as $file) {
         /** @var $file \SplFileInfo */
         if ($file->isDir()) {
             continue;
         }
         $contents .= $this->includeFile($file->getRealPath(), $indent) . "\n";
     }
     return $contents;
 }
开发者ID:jahudka,项目名称:minify,代码行数:16,代码来源:Source.php


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