* * * * @version 1.3.4 * @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 array of the format: * array('class_name_lower_case' => ezcPersistentObjectDefinition ) * * @var array(string=>ezcPersistentObjectDefinition) */ // 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. * * @throws ezcPersistentDefinitionNotFoundException if no such definition can be found. * @throws ezcPersistentDefinitionMissingIdPropertyException * if the definition does not have an "idProperty" attribute. * @param string $class * @return ezcPersistentObjectDefinition */ 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 ezcPersistentDefinitionNotFoundException( $class, "Searched for '" . realpath( dirname( $path ) ) . "/" . basename( $path ) . "'." ); } if ( $definition->idProperty === null ) { throw new ezcPersistentDefinitionMissingIdPropertyException( $class ); } $definition = $this->setupReversePropertyDefinition( $definition ); return $definition; } } ?>