* * * @todo should we cache on this level, int the session or in a separate caching manager? * @package PersistentObject */ class ezcPersistentCodeManager extends ezcPersistentDefinitionManager { /** * Holds the path to the directory where the definitions are stored. * * @var string */ private $dir; /** * Holds the loaded persistent object classes as an arry of the format: * array('class_name_lower_case' => ezcPersistentDefinition ) * * @var array(string=>ezcPersistentDefinition) */ // private $definitions = array(); /** * Constructs a new code manager that will look for persistent object definitions in the directory $dir. * * @param string $dir */ public function __construct( $dir ) { // append trailing / to $dir if it does not exist. if( substr( $dir, strlen( $dir ) - 1, 1) != '/' ) { $dir .= '/'; } $this->dir = $dir; } /** * Returns the definition of the persistent object with the class $class. * * @todo exceptions * @throws ezcPersistentException if no such definition can be found. * @param string $class * @return ezcPersistentDefinition */ public function fetchDefinition( $class ) { $definition = null; $path = $this->dir . strtolower( $class ) . '.php'; if( file_exists( $path ) ) { $definition = require $path; } if( !($definition instanceof ezcPersistentObjectDefinition ) ) { throw new ezcPersistentObjectException( "Could not fetch the persistent object definition for the class '$class'" ); } $definition = $this->setupReversePropertyDefinition( $definition ); return $definition; } } ?>