. */ /** * Tools to support class & package inclusion and referencing. * * @author Hans Lellelid * @version $Revision: 536 $ * @package propel.engine.builder.om */ class ClassTools { /** * Gets just classname, given a dot-path to class. * @param string $qualifiedName * @return string */ public static function classname($qualifiedName) { $pos = strrpos($qualifiedName, '.'); if ($pos === false) { return $qualifiedName; // there is no '.' in the qualifed name } else { return substr($qualifiedName, $pos + 1); // start just after '.' } } /** * Gets the path to be used in include()/require() statement. * * Supports two function signatures: * (1) getFilePath($dotPathClass); * (2) getFilePath($dotPathPrefix, $className); * * @param string $path dot-path to class or to package prefix. * @param string $classname class name * @return string */ public static function getFilePath($path, $classname = null, $extension = '.php') { $path = strtr(ltrim($path, '.'), '.', '/'); if ($classname !== null) { if ($path !== "") { $path .= '/'; } return $path . $classname . $extension; } else { return $path . $extension; } } /** * Gets the basePeer path if specified for table/db. * If not, will return 'propel.util.BasePeer' * @return string */ public static function getBasePeer(Table $table) { $class = $table->getBasePeer(); if ($class === null) { $class = "propel.util.BasePeer"; } return $class; } /** * Gets the baseClass path if specified for table/db. * If not, will return 'propel.om.BaseObject' * @return string */ public static function getBaseClass(Table $table) { $class = $table->getBaseClass(); if ($class === null) { $class = "propel.om.BaseObject"; } return $class; } /** * Gets the interface path if specified for table. * If not, will return 'propel.om.Persistent'. * @return string */ public static function getInterface(Table $table) { $interface = $table->getInterface(); if ($interface === null && !$table->isReadOnly()) { $interface = "propel.om.Persistent"; } return $interface; } }