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


PHP Autoloader::getFileIterator方法代码示例

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


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

示例1: unlink

 */
require_once PATH_DEPENDING . "classes/autoloader/Autoloader.php";
Autoloader::getRegisteredAutoloader()->remove();
$autoloaderIndexFile = PATH_TEMP . "koala_autoloader.gz";
if (DEVELOPMENT_MODE && browserNoCache() && !isAjaxRequest() && !isPhpCli()) {
    if (file_exists($autoloaderIndexFile)) {
        unlink($autoloaderIndexFile);
    }
}
if (dropCache() && !isAjaxRequest()) {
    emptyCacheFolder();
}
$autoloader = new Autoloader(PATH_BASE);
$autoloader->register();
$autoloader->getIndex()->setIndexPath($autoloaderIndexFile);
$autoloader->getFileIterator()->setOnlyDirPattern("~/((core)|(depending)|(extensions))~");
$autoloader->getFileIterator()->setOnlyFilePattern("~\\.php\$~i");
$autoloader->getFileIterator()->addSkipDirPattern("~/((javascript)|(\\.settings)|(\\.todo)|(cache)|(log)|(temp))~");
$autoloader->getFileIterator()->addSkipFilePattern("~/\\.~");
if (apache_getenv("AUTOLOADER_BUILD_RUNNING")) {
    die("System Initialisation is running. Please wait.");
}
if (!file_exists($autoloaderIndexFile)) {
    displayStartupUserInfo();
    try {
        apache_setenv("AUTOLOADER_BUILD_RUNNING", true);
        $autoloader->buildIndex();
        apache_setenv("AUTOLOADER_BUILD_RUNNING", false);
    } catch (AutoloaderException $e) {
        if ($e instanceof AutoloaderException_Parser_IO) {
            die("ERROR: Check you file permissions!");
开发者ID:rolwi,项目名称:koala,代码行数:31,代码来源:core.conf.php

示例2: build

 /**
  * Build and deploy the index
  *
  * @return void
  * @throws AutoloaderException_Builder_NoClassPath
  * @throws AutoloaderException_Builder_NoDeployPath
  * @throws AutoloaderException_Builder_IO
  */
 public function build()
 {
     if (empty($this->_deployPath)) {
         throw new AutoloaderException_Builder_NoDeployPath($this->_locale->sprintf("NO_DEPLOY_PATH"));
     }
     if (empty($this->_classPaths)) {
         throw new AutoloaderException_Builder_NoClassPath($this->_locale->sprintf("NO_CLASS_PATH"));
     }
     $indexDirectory = $this->_deployPath . DIRECTORY_SEPARATOR . "index";
     // Create directories
     $this->_mkdir($this->_deployPath);
     $this->_mkdir($indexDirectory);
     // Build indexes
     foreach ($this->_classPaths as $i => $classPath) {
         $autoloader = new Autoloader($classPath);
         // Setup the deployed index
         $indexFile = "{$i}.php";
         $index = new AutoloaderIndex_PHPArrayCode();
         $index->setIndexPath($indexDirectory . DIRECTORY_SEPARATOR . $indexFile);
         $index->addFilter(new AutoloaderIndexFilter_RelativePath($this->_deployPath));
         // Don't index our own classes
         $autoloader->getFileIterator()->addSkipPattern("/InstantAutoloader\\.php\$/");
         // Build index
         $autoloader->setIndex($index);
         $autoloader->buildIndex();
     }
     // Copy InstantAutoloader
     $isCopied = copy(__DIR__ . DIRECTORY_SEPARATOR . "InstantAutoloader.php", $this->_deployPath . DIRECTORY_SEPARATOR . "InstantAutoloader.php");
     if (!$isCopied) {
         throw new AutoloaderException_Builder_IO($this->_locale->sprintf("FAILED_COPY_INSTANTAUTOLOADER"));
     }
     // Code for autoloading
     $autoloadMethod = $this->_classLoaderMode == self::MODE_AUTOLOAD ? "register" : "requireAll";
     $code = "<?php\n\n" . "/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */\n\n" . "/**\n" . " * Autoloader\n" . " * \n" . " * This code was generated automatically.\n" . " * Don't edit this file. Changes will get lost when\n" . " * building a new autoloader.\n" . " *\n" . " * @see  AutoloaderBuilder::build()\n" . " * @link http://php-autoloader.malkusch.de/en/\n" . " */\n\n" . "namespace " . __NAMESPACE__ . ";\n\n" . "require_once __DIR__ . '/InstantAutoloader.php';\n";
     foreach ($this->_classPaths as $i => $classPath) {
         $indexPath = "__DIR__ . '/index/{$i}.php'";
         $code .= "\n\$_autoloader = new InstantAutoloader({$indexPath});\n" . "\$_autoloader->setBasePath(__DIR__);\n" . "\$_autoloader->{$autoloadMethod}();\n";
     }
     $code .= "unset(\$_autoloader);";
     $isPut = @\file_put_contents($this->getAutoloaderFile(), $code);
     if (!$isPut) {
         $error = \error_get_last();
         throw new AutoloaderException_Builder_IO($this->_locale->sprintf("FAILED_GENERATING_CODE", $error["message"]));
     }
     \chmod($this->getAutoloaderFile(), 0644);
 }
开发者ID:malkusch,项目名称:php-autoloader,代码行数:54,代码来源:AutoloaderBuilder.php


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