Location: PHPKode > projects > Anahita Social Engine > dependencies/plg_system_socialengine/socialengine/domain/description/relationship/abstract.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
 */

abstract class AnDomainDescriptionRelationshipAbstract extends AnDomainDescriptionProperty
{	
	/**
	 * 
	 * @var string
	 */
	protected $_parent_key;
	
	/**
	 * 
	 * @var string
	 */
	protected $_child_key;	
	
	public function __construct($options)
	{
		parent::__construct($options);
		
		$model 		 = new KIdentifier($this->getMapper()->getModel());
		
		$model->name = $this->getName();
		
		$default = array(
			'parent_key' => 'id'   ,
			'model'		 => $model ,
		);
		
		$options 			= array_merge($default, $options);
		
		$this->_child_key   = $options['child_key'];
		
		$this->_model		= $options['model'];
		
		$this->_parent_key  = $options['parent_key'];
	}

	public function validatePresenceOf($value)
	{
		return true;
	}
	
	/**
	 * 
	 * @return 
	 */
	public function getParentKey()
	{
		return $this->_parent_key;
	}
	
	/**
	 * 
	 * @return 
	 */
	public function getChildKey()
	{
		return $this->_child_key;	
	}
		
	/**
	 * 
	 * @return 
	 */
	public function getModel()
	{
		return $this->_model;
	}
	
	/**
	 * 
	 * @return 
	 * @param $model Object
	 */
	public function setModel($model)
	{
		$this->_model = $model;
		if ( isset($this->_query) ) {
			$query = KFactory::get('lib.anahita.domain.factory.query')->get($model);
			$query->update( $this->_query );
			$this->_query = $query;
		}
		return $this;
	}
	
	/**
	 * 
	 * @return 
	 * @param $propertyValue Object
	 */
	public function serialize($propertyValue) {}
	
	/**
	 * 
	 * @return 
	 * @param $propertyValue Object
	 */
	public function materialize($propertyValue) {}	
	
	/**
	 * 
	 * @return 
	 */	
	public function getAttrTree()
	{		
		return array(
			$this->getName() => array(
				$this->getParentKey() => $this->getChildKey()
			)
		);
	}
	
	public function getTableValues($value)
	{
		return array();	
	}
	
	public function getTableFields()
	{
		return array();
	}
	
	/**
	 * 
	 * @return 
	 */
	public function query()
	{
		if ( !isset($this->_query) ) {
			$this->_query = KFactory::get('lib.anahita.domain.factory.query')->get($this->getModel());
		}
		return $this->_query;
	}
	
	/**
	 * Get Target Query
	 * 
	 * @return 
	 */
	public function getTargetQuery()
	{
		return $this->query();
	}
		
	/**
	 * Get the target mapper
	 * 
	 * @return Mapper
	 */	
	public function getTargetMapper()
	{	
		return KFactory::get('lib.anahita.domain.factory.mapper')->get($this->getModel());
	}
				
}
Return current item: Anahita Social Engine