openrat-cms

# OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs

ObjectFactory.php (1358B)


      1 <?php
      2 namespace cms\model;
      3 // OpenRat Content Management System
      4 // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
      5 //
      6 // This program is free software; you can redistribute it and/or
      7 // modify it under the terms of the GNU General Public License
      8 // as published by the Free Software Foundation; either version 2
      9 // of the License, or (at your option) any later version.
     10 //
     11 // This program is distributed in the hope that it will be useful,
     12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 // GNU General Public License for more details.
     15 //
     16 // You should have received a copy of the GNU General Public License
     17 // along with this program; if not, write to the Free Software
     18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
     19 
     20 class ObjectFactory
     21 {
     22 	function create( $objectid )
     23 	{
     24 		$o = new BaseObject( $objectid );
     25 		
     26 		switch( $o->getType() )
     27 		{
     28 			case OR_TYPE_FILE:
     29 				$x = new File( $objectid );
     30 				break;
     31 
     32 			case OR_TYPE_FOLDER:
     33 				$x = new Folder( $objectid );
     34 				break;
     35 
     36 			case OR_TYPE_PAGE:
     37 				$x = new Page( $objectid );
     38 				break;
     39 
     40 			case OR_TYPE_LINK:
     41 				$x = new Link( $objectid );
     42 				break;
     43 
     44 			default:
     45 				throw new \LogicException( "Unknown Object-Typ: ".$o->getType() );
     46 		}
     47 		
     48 		$x->load();
     49 		return $x;
     50 	}
     51 }
     52 
     53 ?>