[pLog-svn] r466 - plog/trunk/class/controller

oscar at devel.plogworld.net oscar at devel.plogworld.net
Fri Dec 10 15:23:58 GMT 2004


Author: oscar
Date: 2004-12-10 15:23:57 +0000 (Fri, 10 Dec 2004)
New Revision: 466

Modified:
   plog/trunk/class/controller/controller.class.php
   plog/trunk/class/controller/resourceclassloader.class.php
Log:
added ResourceClassLoader::getLoader() as a static singleton-like method so that there is only one instance of the class loader in 
all situations...


Modified: plog/trunk/class/controller/controller.class.php
===================================================================
--- plog/trunk/class/controller/controller.class.php	2004-12-10 14:48:47 UTC (rev 465)
+++ plog/trunk/class/controller/controller.class.php	2004-12-10 15:23:57 UTC (rev 466)
@@ -97,7 +97,8 @@
 			$this->actionFolderPath = PLOG_CLASS_PATH.'class/action/';
 
 		// folder where classes can be loaded
-		$this->_loader = new ResourceClassLoader( $this->actionFolderPath );
+		//$this->_loader = new ResourceClassLoader( $this->actionFolderPath );
+		$this->_loader =& ResourceClassLoader::getLoader( $this->actionFolderPath );
         }
 		
 		/**

Modified: plog/trunk/class/controller/resourceclassloader.class.php
===================================================================
--- plog/trunk/class/controller/resourceclassloader.class.php	2004-12-10 14:48:47 UTC (rev 465)
+++ plog/trunk/class/controller/resourceclassloader.class.php	2004-12-10 15:23:57 UTC (rev 466)
@@ -12,12 +12,14 @@
 		var $_classFileSuffix;
 
 		/**
-		 * initializes the class loader
+		 * initializes the class loader. It is advisable to use the 
+		 * static ResourceClassLoader::getClass method
 		 *
  		 * @param path The starting path where classes can be loaded
 		 * @param classFileSuffix default suffix that each class file will have
+		 * @static
 		 */
-		function ResourceClassLoader( $path, $classFileSuffix = '.class.php' )
+		function ResourceClassLoader( $path = ".", $classFileSuffix = '.class.php' )
 		{
 			$this->Object();
 
@@ -26,6 +28,26 @@
 		}
 
 		/**
+		 * static method that returns a single instance of this class
+		 *
+		 * @static
+		 * @param path 
+		 * @return a ResourceClassLoader object
+		 */
+		function getLoader( $path = "./" )
+		{
+			static $instance;
+
+			if( $instance == null ) {
+				$instance = new ResourceClassLoader( $path );
+			}
+			else
+				$instance->addSearchFolder( $path );
+		
+			return $instance;
+		}
+
+		/**
 		 * adds a new folder to the list of folders to be searched
 		 * 
 		 * @param folder
@@ -37,6 +59,19 @@
 
 			return true;
 		}
+
+		/**
+		 * sets a new suffix for class files
+		 *
+		 * @param suffix
+		 * @return always true
+		 */
+		function setClassFileSuffix( $suffix )
+		{
+			$this->_classFileSuffix = $suffix;
+
+			return true;
+		}
 		
 		/**
 		 * loads classes from disk using the list of folders that has been provided. The




More information about the pLog-svn mailing list