Author: dr
Date: Mon Jan 14 11:31:27 2008
New Revision: 7144

Log:
- Implemented issue #11506: Added the static method
  ezcBase::getInstallationPath().

Modified:
    trunk/Base/ChangeLog
    trunk/Base/src/base.php
    trunk/Base/tests/base_test.php

Modified: trunk/Base/ChangeLog
==============================================================================
--- trunk/Base/ChangeLog [iso-8859-1] (original)
+++ trunk/Base/ChangeLog [iso-8859-1] Mon Jan 14 11:31:27 2008
@@ -1,3 +1,10 @@
+1.5alpha1 - [RELEASEDATE]
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+- Implemented issue #11506: Added the static method
+  ezcBase::getInstallationPath().
+
+
 1.4.1 - Monday 14 January 2008
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

Modified: trunk/Base/src/base.php
==============================================================================
--- trunk/Base/src/base.php [iso-8859-1] (original)
+++ trunk/Base/src/base.php [iso-8859-1] Mon Jan 14 11:31:27 2008
@@ -46,7 +46,7 @@
      *
      * @var string
      */
-    protected static $packageDir;
+    protected static $packageDir = null;
 
     /**
      * Stores info with additional paths where autoload files and classes for
@@ -209,14 +209,19 @@
     }
 
     /**
-     * Returns the path to the autoload directory. The path depends on
-     * the installation of the ezComponents. The SVN version has different
-     * paths than the PEAR installed version. (For now).
-     *
-     * @return string
+     * Figures out the base path of the eZ Components installation.
+     *
+     * It stores the path that it finds in a static member variable. The path
+     * depends on the installation method of the eZ Components. The SVN version
+     * has a different path than the PEAR installed version.
      */
     protected static function setPackageDir()
     {
+        if ( ezcBase::$packageDir !== null )
+        {
+            return;
+        }
+
         // Get the path to the components.
         $baseDir = dirname( __FILE__ );
 
@@ -548,7 +553,7 @@
         if ( $prefix === null )
         {
             $array = array( 'basePath' => $basePath, 'autoloadDirPath' => 
$autoloadDirPath );
- 
+
             // add info to the list of extra dirs
             ezcBase::$repositoryDirs[] = $array;
         }
@@ -558,10 +563,22 @@
             {
                 throw new ezcBaseDoubleClassRepositoryPrefixException( 
$prefix, $basePath, $autoloadDirPath );
             }
- 
+
             // add info to the list of extra dirs, and use the prefix to 
identify the new repository.
             ezcBase::$repositoryDirs[$prefix] = array( 'basePath' => 
$basePath, 'autoloadDirPath' => $autoloadDirPath );
         }
     }
+
+    /**
+     * Returns the base path of the eZ Components installation
+     *
+     * @return string
+     */
+    public static function getInstallationPath()
+    {
+        self::setPackageDir();
+
+        return realpath( self::$packageDir );
+    }
 }
 ?>

Modified: trunk/Base/tests/base_test.php
==============================================================================
--- trunk/Base/tests/base_test.php [iso-8859-1] (original)
+++ trunk/Base/tests/base_test.php [iso-8859-1] Mon Jan 14 11:31:27 2008
@@ -467,6 +467,13 @@
         }
     }
 
+    public function testGetInstallationPath()
+    {
+        $path = ezcBase::getInstallationPath();
+        $pathParts = explode( DIRECTORY_SEPARATOR, $path );
+        self::assertEquals( array( 'trunk' ), array_splice( $pathParts, -1 ) );
+    }
+
     public function setup()
     {
         $options = new ezcBaseAutoloadOptions;


-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to