Location: PHPKode > projects > Anahita Social Engine > dependencies/plg_system_socialengine/socialengine/domain/factory/factory.php
<?php
/**
 * @version		1.0.0
 * @category	Anahita Social Engine™
 * @copyright	Copyright (C) 2008 - 2010 rmdStudio Inc. and Peerglobe Technology Inc. All rights reserved.
 * @license		GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
 * @link     	http://www.anahitapolis.com
 */

class AnDomainFactory
{
		
	protected $_mappers	 = array();
		
	/**
	 * return a mapper for an identifier (model)
	 * @return 
	 * @param $identifier Object
	 */
	public function getMapper($model)
	{
		$model = (string) $model;
		
		if ( !isset($this->_mappers[$model]) ) {
			
			$mapper    = KFactory::tmp('lib.anahita.domain.mapper', array(
				'model' => $model
			));
			
			$this->_mappers[$model] = $mapper;
		}
		return $this->_mappers[$model];
	}
	
	/**
	 * return a fresh instance of the model. this is not a cloned object. don't use this
	 * for mass instantiation 
	 * @return 
	 * @param $model Object
	 * @param $properties Object[optional]
	 */
	public function getInstance($model, $properties = array())
	{
		$mapper     = $this->getMapper($model);
		$instance   = $mapper->getInstance(false);
		$instance->setProperty($properties);
		$instance->awakeFromInsert();		
		return $instance;
	}
	
	public function getRepository($model)
	{
		$mapper = $this->getMapper($model);
		return $mapper->getRepository();
	}
	
	public function getQuery($model)
	{
		$mapper = $this->getMapper($model);
		return $mapper->getQuery();
	}
	
}

Return current item: Anahita Social Engine