dmBridge PHP API
DMObjectFactory.php
00001 <?php
00002 #
00003 # dmBridge: a data access framework for CONTENTdm(R)
00004 #
00005 # Copyright © 2009, 2010, 2011 Board of Regents of the Nevada System of Higher
00006 # Education, on behalf of the University of Nevada, Las Vegas
00007 #
00008 
00013 abstract class DMObjectFactory {
00014 
00019    private static $object_cache = array();
00020 
00028    public static function getObject(DMCollection $c, $ptr) {
00029       $key = $c->getAlias() . $ptr;
00030 
00031       foreach (self::$object_cache as $cache_key => $cache_value) {
00032          if ($cache_key == $key) {
00033             return $cache_value;
00034          }
00035       }
00036 
00037       if (!DMObject::exists($c, $ptr)) {
00038          throw new DMUnavailableModelException(
00039                DMLocalizedString::getString("INVALID_OBJECT"));
00040       }
00041       $obj = new DMObject($c, $ptr, DMDataStoreFactory::getDataStore(),
00042             DMConfigIni::getInstance());
00043       self::$object_cache[$key] = $obj;
00044       return self::$object_cache[$key];
00045    }
00046 
00047 }
 All Data Structures Functions Variables