コード例 #1
0
 /**
  * Import a PHP file
  *
  * @param  string $path      Path to the PHP file
  * @param  mixed  $classpath String or object supporting __toString()
  *
  * @throws ConfigurationException
  */
 public static function __import($path, $classpath = null)
 {
     if ($classpath) {
         // Apparently casting to (string) no longer invokes __toString() automatically.
         if (is_object($classpath)) {
             $classpath = $classpath->__toString();
         }
         // classpaths are currently additive, but we also don't want to just
         // indiscriminantly prepand/append stuff to the include_path.  This means
         // we need to parse current incldue_path, and prepend any
         // specified classpath locations that are not already in the include_path.
         //
         // NOTE:  the reason why we do it this way instead of just changing include_path
         // and then changing it back, is that in many cases applications (e.g. Propel) will
         // include/require class files from within method calls.  This means that not all
         // necessary files will be included in this import() call, and hence we can't
         // change the include_path back without breaking those apps.  While this method could
         // be more expensive than switching & switching back (not sure, but maybe), it makes it
         // possible to write far less expensive run-time applications (e.g. using Propel), which is
         // really where speed matters more.
         $curr_parts = Phing::explodeIncludePath();
         $add_parts = Phing::explodeIncludePath($classpath);
         $new_parts = array_diff($add_parts, $curr_parts);
         if ($new_parts) {
             set_include_path(implode(PATH_SEPARATOR, array_merge($new_parts, $curr_parts)));
         }
     }
     $ret = (include_once $path);
     if ($ret === false) {
         $msg = "Error importing {$path}";
         if (self::getMsgOutputLevel() >= Project::MSG_DEBUG) {
             $x = new Exception("for-path-trace-only");
             $msg .= $x->getTraceAsString();
         }
         throw new ConfigurationException($msg);
     }
 }
コード例 #2
0
 /**
  * The init method: check if Net_FTP is available
  */
 public function init()
 {
     require_once 'PEAR.php';
     $paths = Phing::explodeIncludePath();
     foreach ($paths as $path) {
         if (file_exists($path . DIRECTORY_SEPARATOR . 'Net' . DIRECTORY_SEPARATOR . 'FTP.php')) {
             return true;
         }
     }
     throw new BuildException('The FTP Deploy task requires the Net_FTP PEAR package.');
 }
コード例 #3
0
 /**
  * Finds and initializes the phpDocumentor installation
  */
 private function initializePhpDocumentor()
 {
     $phpDocumentorPath = null;
     foreach (Phing::explodeIncludePath() as $path) {
         $testPhpDocumentorPath = $path . DIRECTORY_SEPARATOR . 'phpDocumentor' . DIRECTORY_SEPARATOR . 'src';
         if (file_exists($testPhpDocumentorPath)) {
             $phpDocumentorPath = $testPhpDocumentorPath;
         }
     }
     if (empty($phpDocumentorPath)) {
         throw new BuildException("Please make sure PhpDocumentor 2 is installed and on the include_path.", $this->getLocation());
     }
     set_include_path($phpDocumentorPath . PATH_SEPARATOR . get_include_path());
     require_once $phpDocumentorPath . '/phpDocumentor/Bootstrap.php';
     \phpDocumentor\Bootstrap::createInstance()->initialize();
     $this->phpDocumentorPath = $phpDocumentorPath;
 }
コード例 #4
0
 /**
  * Searches include_path for PhpDocumentor install and adjusts include_path appropriately.
  * @throws BuildException - if unable to find PhpDocumentor on include_path
  */
 protected function findPhpDocumentorInstall()
 {
     $found = null;
     foreach (Phing::explodeIncludePath() as $path) {
         $testpath = $path . DIRECTORY_SEPARATOR . 'PhpDocumentor';
         if (file_exists($testpath)) {
             $found = $testpath;
             break;
         }
     }
     if (!$found) {
         throw new BuildException("PhpDocumentor task depends on PhpDocumentor being installed and on include_path.", $this->getLocation());
     }
     // otherwise, adjust the include_path to path to include the PhpDocumentor directory ...
     set_include_path(get_include_path() . PATH_SEPARATOR . $found);
     include_once "phpDocumentor/Setup.inc.php";
     if (!class_exists('phpDocumentor_setup')) {
         throw new BuildException("Error including PhpDocumentor setup class file.");
     }
 }
コード例 #5
0
 /** Main entry point */
 public function main()
 {
     // Apparently casting to (string) no longer invokes __toString() automatically.
     if (is_object($this->classpath)) {
         $classpath = $this->classpath->__toString();
     }
     if (empty($classpath)) {
         throw new BuildException("Provided classpath was empty.");
     }
     $curr_parts = Phing::explodeIncludePath();
     $add_parts = Phing::explodeIncludePath($classpath);
     $new_parts = array_diff($add_parts, $curr_parts);
     if ($new_parts) {
         $this->log("Prepending new include_path components: " . implode(PATH_SEPARATOR, $new_parts), Project::MSG_VERBOSE);
         set_include_path(implode(PATH_SEPARATOR, array_merge($new_parts, $curr_parts)));
     }
 }
コード例 #6
0
 /**
  * Find the correct php documentor path
  *
  * @return null|string
  */
 private function findPhpDocumentorPath()
 {
     $phpDocumentorPath = null;
     $directories = array('phpDocumentor', 'phpdocumentor');
     foreach ($directories as $directory) {
         foreach (Phing::explodeIncludePath() as $path) {
             $testPhpDocumentorPath = $path . DIRECTORY_SEPARATOR . $directory . DIRECTORY_SEPARATOR . 'src';
             if (file_exists($testPhpDocumentorPath)) {
                 $phpDocumentorPath = $testPhpDocumentorPath;
             }
         }
     }
     return $phpDocumentorPath;
 }
コード例 #7
0
 /** Main entry point */
 public function main()
 {
     // Apparently casting to (string) no longer invokes __toString() automatically.
     if (is_object($this->classpath)) {
         $classpath = $this->classpath->__toString();
     }
     if (empty($classpath)) {
         throw new BuildException("Provided classpath was empty.");
     }
     $curr_parts = Phing::explodeIncludePath();
     $add_parts = Phing::explodeIncludePath($classpath);
     $new_parts = array_diff($add_parts, $curr_parts);
     if ($new_parts) {
         $this->updateIncludePath($new_parts, $curr_parts);
     }
 }
コード例 #8
0
 /**
  * Finds and initializes the DocBlox installation
  */
 private function initializeDocBlox()
 {
     $docbloxPath = null;
     foreach (Phing::explodeIncludePath() as $path) {
         $testDocBloxPath = $path . DIRECTORY_SEPARATOR . 'DocBlox' . DIRECTORY_SEPARATOR . 'src';
         if (file_exists($testDocBloxPath)) {
             $docbloxPath = $testDocBloxPath;
         }
     }
     if (empty($docbloxPath)) {
         throw new BuildException("Please make sure DocBlox is installed and on the include_path.", $this->getLocation());
     }
     set_include_path($docbloxPath . PATH_SEPARATOR . get_include_path());
     require_once $docbloxPath . '/DocBlox/Bootstrap.php';
     $bootstrap = DocBlox_Bootstrap::createInstance();
     $autoloader = $bootstrap->registerAutoloader();
     if ($this->quiet) {
         DocBlox_Core_Abstract::config()->logging->level = 'quiet';
     } else {
         DocBlox_Core_Abstract::config()->logging->level = 'debug';
     }
     $bootstrap->registerPlugins($autoloader);
 }