Author: Derick Rethans
Date: 2007-04-03 14:34:18 +0200 (Tue, 03 Apr 2007)
New Revision: 4802

Log:
- Fixed issue #8433: ezcBase::getRepositoryDirectories() problems.

Added:
   trunk/Base/src/structs/
   trunk/Base/src/structs/repository_directory.php
Modified:
   trunk/Base/ChangeLog
   trunk/Base/src/base.php
   trunk/Base/src/base_autoload.php
   trunk/Base/src/exceptions/autoload.php
   trunk/Base/tests/base_test.php

Modified: trunk/Base/ChangeLog
===================================================================
--- trunk/Base/ChangeLog        2007-04-03 08:29:40 UTC (rev 4801)
+++ trunk/Base/ChangeLog        2007-04-03 12:34:18 UTC (rev 4802)
@@ -1,6 +1,7 @@
 1.3beta1 - [RELEASEDATE]
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+- Fixed issue #8433: ezcBase::getRepositoryDirectories() problems.
 - Implemented issue #9569: Add "autoload.php" as 3rd fallback autoload file to
   search for.
 - Added exception class ezcBaseExtensionNotFoundException to be thrown when an

Modified: trunk/Base/src/base.php
===================================================================
--- trunk/Base/src/base.php     2007-04-03 08:29:40 UTC (rev 4801)
+++ trunk/Base/src/base.php     2007-04-03 12:34:18 UTC (rev 4802)
@@ -381,23 +381,21 @@
      * 
      * The path to the eZ components directory is always included in the result
      * array. Each element in the returned array has the format of:
-     * packageDirectory => array( $type, autoloadDirectory )
-     * The $type is either "ezc" for the eZ components directory or "external"
-     * for external repositories.
+     * packageDirectory => ezcBaseRepositoryDirectory
      *
-     * @return array(string=>array)
-     * @access private
+     * @return array(string=>ezcBaseRepositoryDirectory)
      */
     public static function getRepositoryDirectories()
     {
         $autoloadDirs = array();
         ezcBase::setPackageDir();
         $repositoryDir = self::$currentWorkingDirectory ? 
self::$currentWorkingDirectory : ( realpath( dirname( __FILE__ ) . '/../../' ) 
);
-        $autoloadDirs['ezc'] = array( 'ezc', $repositoryDir . "/autoload" );
+        $autoloadDirs['ezc'] = new ezcBaseRepositoryDirectory( 
ezcBaseRepositoryDirectory::TYPE_INTERNAL, $repositoryDir, $repositoryDir . 
"/autoload" );
 
         foreach ( ezcBase::$repositoryDirs as $extraDirKey => $extraDirArray )
         {
-            $autoloadDirs[$extraDirKey] = array( 'external', 
$extraDirArray['autoloadDirPath'] );
+            $repositoryDirectory = new ezcBaseRepositoryDirectory( 
ezcBaseRepositoryDirectory::TYPE_EXTERNAL, realpath( $extraDirArray['basePath'] 
), realpath( $extraDirArray['autoloadDirPath'] ) );
+            $autoloadDirs[$extraDirKey] = $repositoryDirectory;
         }
         
         return $autoloadDirs;

Modified: trunk/Base/src/base_autoload.php
===================================================================
--- trunk/Base/src/base_autoload.php    2007-04-03 08:29:40 UTC (rev 4801)
+++ trunk/Base/src/base_autoload.php    2007-04-03 12:34:18 UTC (rev 4802)
@@ -14,6 +14,8 @@
     'ezcBaseOptions'                       => 'Base/options.php',
     'ezcBaseStruct'                        => 'Base/struct.php',
 
+    'ezcBaseRepositoryDirectory'           => 
'Base/structs/repository_directory.php',
+
     'ezcBaseException'                     => 'Base/exceptions/exception.php',
     'ezcBaseFileException'                 => 
'Base/exceptions/file_exception.php',
 

Modified: trunk/Base/src/exceptions/autoload.php
===================================================================
--- trunk/Base/src/exceptions/autoload.php      2007-04-03 08:29:40 UTC (rev 
4801)
+++ trunk/Base/src/exceptions/autoload.php      2007-04-03 12:34:18 UTC (rev 
4802)
@@ -26,7 +26,7 @@
         $paths = array();
         foreach ( $dirs as $dir )
         {
-            $paths[] = realpath( $dir[1] );
+            $paths[] = realpath( $dir->autoloadPath );
         }
         parent::__construct( "Could not find a class to file mapping for 
'{$className}'. Searched for ". implode( ', ', $files ) . " in: " . implode( ', 
', $paths ) );
     }

Added: trunk/Base/src/structs/repository_directory.php
===================================================================
--- trunk/Base/src/structs/repository_directory.php     2007-04-03 08:29:40 UTC 
(rev 4801)
+++ trunk/Base/src/structs/repository_directory.php     2007-04-03 12:34:18 UTC 
(rev 4802)
@@ -0,0 +1,81 @@
+<?php
+/**
+ * File containing the ezcBaseRepositoryDirectory.
+ *
+ * @package Base
+ * @version //autogentag//
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * @package Base
+ * @version //autogentag//
+ */
+class ezcBaseRepositoryDirectory extends ezcBaseStruct
+{
+    /**
+     * Specifies that the entry is for the eZ Components repository.
+     */
+    const TYPE_INTERNAL = 0;
+
+    /**
+     * Specifies that the entry is for an external (user defined) repository.
+     */
+    const TYPE_EXTERNAL = 1;
+
+    /**
+     * The $type is one of the two TYPE_* constants defined in this class.
+     *
+     * @var string
+     */
+    public $type;
+
+    /**
+     * The path to the configured repository
+     *
+     * @var string
+     */
+    public $basePath;
+
+    /**
+     * The path to the autoload files
+     *
+     * @var string
+     */
+    public $autoloadPath;
+
+    /**
+     * Constructs a new ezcBaseRepositoryDirectory of type $type with base path
+     * $basePath and autoload path $autoloadPath.
+     *
+     * @param string $type
+     * @param string $basePath
+     * @param string $autoloadPath
+     */
+    public function __construct( $type, $basePath, $autoloadPath )
+    {
+        $this->type = $type;
+        $this->basePath = $basePath;
+        $this->autoloadPath = $autoloadPath;
+    }
+
+    /**
+     * Returns a new instance of this class with the data specified by $array.
+     *
+     * $array contains all the data members of this class in the form:
+     * array('member_name'=>value).
+     *
+     * __set_state makes this class exportable with var_export.
+     * var_export() generates code, that calls this method when it
+     * is parsed with PHP.
+     *
+     * @param array(string=>mixed)
+     * @return ezcBaseRepositoryDirectory
+     */
+    static public function __set_state( array $array )
+    {
+        return new ezcBaseRepositoryDirectory( $array['type'], 
$array['basePath'], $array['autoloadPath'] );
+    }
+}
+?>


Property changes on: trunk/Base/src/structs/repository_directory.php
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/Base/tests/base_test.php
===================================================================
--- trunk/Base/tests/base_test.php      2007-04-03 08:29:40 UTC (rev 4801)
+++ trunk/Base/tests/base_test.php      2007-04-03 12:34:18 UTC (rev 4802)
@@ -309,10 +309,15 @@
            $this->fail( "No packageDir found in result of 
getRepositoryDirectories()" );
         }
 
-        if ( !isset( $resultArray[0] ) || $resultArray[0][1] != './autoload' )
+        if ( !isset( $resultArray[0] ) || $resultArray[0]->basePath != 
getcwd() )
         {
-            $this->fail( "Extra autoload dir '{$resultArray['.'][1]}' is added 
incorrectly" );
+            $this->fail( "Extra base dir '{$resultArray[0]->basePath}' is 
added incorrectly" );
         }
+
+        if ( !isset( $resultArray[0] ) || $resultArray[0]->autoloadPath != 
getcwd() . '/autoload' )
+        {
+            $this->fail( "Extra autoload dir '{$resultArray[0]->autoloadPath}' 
is added incorrectly" );
+        }
     }
 
     // this test is sorta obsolete, but we keep it around for good measure
@@ -333,9 +338,9 @@
            $this->fail( "No packageDir found in result of 
getRepositoryDirectories()" );
         }
 
-        if ( !isset( $resultArray[2] ) || $resultArray[2][1] != 
'./Base/tests/test_repository/autoload_files' )
+        if ( !isset( $resultArray[2] ) || $resultArray[2]->autoloadPath != 
getcwd() . '/Base/tests/test_repository/autoload_files' )
         {
-            $this->fail( "Extra autoload dir '{$resultArray[2][1]}' is added 
incorrectly" );
+            $this->fail( "Extra autoload dir '{$resultArray[2]->autoloadPath}' 
is added incorrectly" );
         }
 
         self::assertEquals( true, class_exists( 'trBasetestClass', true ) );
@@ -395,6 +400,9 @@
 
         self::assertEquals( true, array_key_exists( 'ezc', $resultArray ) );
         self::assertEquals( true, array_key_exists( 'tr', $resultArray ) );
+
+        self::assertEquals( getcwd() . '/Base/tests/test_repository', 
$resultArray['tr']->basePath );
+        self::assertEquals( getcwd() . 
'/Base/tests/test_repository/autoload_files', $resultArray['tr']->autoloadPath 
);
     }
 
     public function testNoPrefixAutoload()

-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to