[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 /* 3 * $Id: ClassTools.php 64 2005-05-13 02:43:56Z root $ 4 * 5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 * 17 * This software consists of voluntary contributions made by many individuals 18 * and is licensed under the LGPL. For more information please see 19 * <http://propel.phpdb.org>. 20 */ 21 22 23 /** 24 * Tools to support class & package inclusion and referencing. 25 * 26 * @author Hans Lellelid <hans@xmpl.org> 27 * @version $Revision: 64 $ 28 * @package propel.engine.builder.om 29 */ 30 class ClassTools { 31 32 /** 33 * Gets just classname, given a dot-path to class. 34 * @param string $qualifiedName 35 * @return string 36 */ 37 public static function classname($qualifiedName) 38 { 39 $pos = strrpos($qualifiedName, '.'); 40 if ($pos === false) { 41 return $qualifiedName; // there is no '.' in the qualifed name 42 } else { 43 return substr($qualifiedName, $pos + 1); // start just after '.' 44 } 45 } 46 47 /** 48 * Gets the path to be used in include()/require() statement. 49 * 50 * Supports two function signatures: 51 * (1) getFilePath($dotPathClass); 52 * (2) getFilePath($dotPathPrefix, $className); 53 * 54 * @param string $path dot-path to class or to package prefix. 55 * @param string $classname class name 56 * @return string 57 */ 58 public static function getFilePath($path, $classname = null, $extension = '.php') 59 { 60 $path = strtr(ltrim($path, '.'), '.', '/'); 61 if ($classname !== null) { 62 if ($path !== "") { $path .= '/'; } 63 return $path . $classname . $extension; 64 } else { 65 return $path . $extension; 66 } 67 } 68 69 /** 70 * Gets the basePeer path if specified for table/db. 71 * If not, will return 'propel.util.BasePeer' 72 * @return string 73 */ 74 public static function getBasePeer(Table $table) { 75 $class = $table->getBasePeer(); 76 if ($class === null) { 77 $class = "propel.util.BasePeer"; 78 } 79 return $class; 80 } 81 82 /** 83 * Gets the baseClass path if specified for table/db. 84 * If not, will return 'propel.om.BaseObject' 85 * @return string 86 */ 87 public static function getBaseClass(Table $table) { 88 $class = $table->getBaseClass(); 89 if ($class === null) { 90 $class = "propel.om.BaseObject"; 91 } 92 return $class; 93 } 94 95 /** 96 * Gets the interface path if specified for table. 97 * If not, will return 'propel.om.Persistent'. 98 * @return string 99 */ 100 public static function getInterface(Table $table) { 101 $interface = $table->getInterface(); 102 if ($interface === null && !$table->isReadOnly()) { 103 $interface = "propel.om.Persistent"; 104 } 105 return $interface; 106 } 107 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |