Пример #1
0
 /**
  * set entities in relation
  *
  * @access public
  * @param Ultimate_ModuleCreator_Model_Entity $entity1
  * @param Ultimate_ModuleCreator_Model_Entity $entity2
  * @param int $type
  * @return Ultimate_ModuleCreator_Model_Relation
  * @author Marius Strajeru <*****@*****.**>
  */
 public function setEntities(Ultimate_ModuleCreator_Model_Entity $entity1, Ultimate_ModuleCreator_Model_Entity $entity2, $type)
 {
     $this->_entity1 = $entity1;
     $this->_entity2 = $entity2;
     $this->_type = $type;
     switch ($type) {
         case self::RELATION_TYPE_NONE:
             break;
         case self::RELATION_TYPE_CHILD:
             $this->_entity1->addRelatedEntity($type, $this->_entity2);
             $this->_entity2->addRelatedEntity(self::RELATION_TYPE_PARENT, $this->_entity1);
             break;
         case self::RELATION_TYPE_PARENT:
             $this->_entity1->addRelatedEntity($type, $this->_entity2);
             $this->_entity2->addRelatedEntity(self::RELATION_TYPE_CHILD, $this->_entity1);
             break;
         case self::RELATION_TYPE_SIBLING:
             $this->_entity1->addRelatedEntity($type, $this->_entity2);
             $this->_entity2->addRelatedEntity(self::RELATION_TYPE_SIBLING, $this->_entity1);
             break;
         default:
             break;
     }
     return $this;
 }