Пример #1
0
 protected function _setupAssociations()
 {
     $associations = $this->_associations;
     $this->_associations = array();
     foreach ($associations as $association_data) {
         $association = new SimDAL_Mapper_Association($this, $association_data);
         $this->_associations[$association->getIdentifier()] = $association;
     }
 }
Пример #2
0
 protected static function _generateProxyMethodForManyToOneAssociation(SimDAL_Mapper_Association $association, SimDAL_Mapper_Entity $mapping)
 {
     $method = ucfirst($association->getMethod());
     $getter = 'get' . $method;
     $setter = 'set' . $method;
     $output = '';
     $output .= '	public function ' . $getter . '($load=true) {' . PHP_EOL;
     $output .= '		if ($load && !$this->_isSimDALAssociationLoaded(\'' . $association->getMethod() . '\')) {' . PHP_EOL;
     $output .= '			$session = $this->_getSession();' . PHP_EOL;
     $output .= '			$foreign_key = $this->get' . ucfirst($association->getForeignKey()) . '();' . PHP_EOL;
     $output .= '			if (!is_null($foreign_key)) {' . PHP_EOL;
     $output .= '				$this->' . $setter . '(' . PHP_EOL;
     $output .= '					$session->load(\'' . $association->getClass() . '\')' . PHP_EOL;
     $output .= '					->whereColumn(\'' . $association->getParentKey() . '\')' . PHP_EOL;
     $output .= '					->equals($foreign_key)' . PHP_EOL;
     $output .= '					->fetch()' . PHP_EOL;
     $output .= '				);' . PHP_EOL;
     $output .= '			}' . PHP_EOL;
     $output .= '			$this->_SimDALAssociationIsLoaded(\'' . $association->getMethod() . '\');' . PHP_EOL;
     $output .= '		}' . PHP_EOL;
     $output .= '		return parent::' . $getter . '();' . PHP_EOL;
     $output .= '	}' . PHP_EOL . PHP_EOL;
     $output .= '	public function ' . $setter . '(' . $association->getClass() . ' $value=null, $set_circlic_ref=true) {' . PHP_EOL;
     $output .= '		if (!is_null($value)) {' . PHP_EOL;
     $output .= '			$this->' . $association->getForeignKey() . ' = $value->get' . ucfirst($association->getParentKey()) . '();' . PHP_EOL;
     $output .= '			if (!$this->_getSession()->isLoaded($value) && !$this->_getSession()->isAdded($value)) {' . PHP_EOL;
     $output .= '				$this->_getSession()->addEntity($value);' . PHP_EOL;
     $output .= '			}' . PHP_EOL;
     $output .= '		}' . PHP_EOL;
     $output .= '		$this->_SimDALAssociationIsLoaded(\'' . $association->getMethod() . '\');' . PHP_EOL;
     $output .= '		parent::' . $setter . '($value);' . PHP_EOL . PHP_EOL;
     $output .= '		if (!is_null($value) && $set_circlic_ref) {' . PHP_EOL;
     $output .= '			$value->_simDAL_SetReference($this, $this->_SimDAL_GetAssociation(\'' . $association->getIdentifier() . '\'));' . PHP_EOL;
     $output .= '		}' . PHP_EOL;
     $output .= '	}' . PHP_EOL . PHP_EOL;
     return $output;
 }
Пример #3
0
 public function getRightValue()
 {
     return $this->_association->getParentKey();
 }