AbstractProtoClass.class.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  *   Copyright (C) 2006-2007 by Konstantin V. Arkhipov                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation; either version 3 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  ***************************************************************************/
00011 /* $Id: AbstractProtoClass.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012 
00016     abstract class AbstractProtoClass extends Singleton
00017     {
00018         abstract protected function makePropertyList();
00019         abstract protected function makeForm();
00020         
00021         final public function getPropertyList()
00022         {
00023             static $lists = array();
00024             
00025             $className = get_class($this);
00026             
00027             if (!isset($lists[$className])) {
00028                 $lists[$className] = $this->makePropertyList();
00029             }
00030             
00031             return $lists[$className];
00032         }
00033         
00038         public function getPropertyByName($name)
00039         {
00040             $list = $this->getPropertyList();
00041             
00042             if (isset($list[$name]))
00043                 return $list[$name];
00044             
00045             throw new MissingElementException(
00046                 'unknown property requested by name '."'{$name}'"
00047             );
00048         }
00049         
00050         public function getMapping()
00051         {
00052             $mapping = array();
00053             
00054             foreach ($this->getPropertyList() as $name => $property) {
00055                 if (
00056                     !$property->getRelationId()
00057                     || (
00058                         $property->getRelationId()
00059                         == MetaRelation::ONE_TO_ONE
00060                     ) || (
00061                         $property->getFetchStrategyId()
00062                         == FetchStrategy::LAZY
00063                     )
00064                 ) {
00065                     $mapping[$name] = $property->getColumnName();
00066                 }
00067             }
00068             
00069             return $mapping;
00070         }
00071     }
00072 ?>

Generated on Sun Dec 9 21:56:23 2007 for onPHP by  doxygen 1.5.4