コード例 #1
0
ファイル: File.php プロジェクト: alefernie/intranet
 /**
  * fromReflectedFileName() - use this if you intend on generating code generation objects based on the same file.
  * This will keep previous changes to the file in tact during the same PHP process
  *
  * @param string $filePath
  * @param bool $usePreviousCodeGeneratorIfItExists
  * @param bool $includeIfNotAlreadyIncluded
  * @return Zend_CodeGenerator_Php_File
  */
 public static function fromReflectedFileName($filePath, $usePreviousCodeGeneratorIfItExists = true, $includeIfNotAlreadyIncluded = true)
 {
     $realpath = realpath($filePath);
     if ($realpath === false) {
         if (($realpath = Zend_Reflection_File::findRealpathInIncludePath($filePath)) === false) {
             // require_once 'Zend/CodeGenerator/Php/Exception.php';
             throw new Zend_CodeGenerator_Php_Exception('No file for ' . $realpath . ' was found.');
         }
     }
     if ($usePreviousCodeGeneratorIfItExists && isset(self::$_fileCodeGenerators[$realpath])) {
         return self::$_fileCodeGenerators[$realpath];
     }
     if ($includeIfNotAlreadyIncluded && !in_array($realpath, get_included_files())) {
         include $realpath;
     }
     $codeGenerator = self::fromReflection($fileReflector = new Zend_Reflection_File($realpath));
     if (!isset(self::$_fileCodeGenerators[$fileReflector->getFileName()])) {
         self::$_fileCodeGenerators[$fileReflector->getFileName()] = $codeGenerator;
     }
     return $codeGenerator;
 }