/**
  *
  * @param string $pType
  * @param Model_ZupalatomIF $pTarget
  * @param bool $pSingular
  * @param Model_ZupalatomIF $bond_atom
  * @return Model_Zupalbonds
  */
 public function bond_to($pType, Model_ZupalatomIF $pTarget, $pSingular = TRUE, Model_ZupalatomIF $bond_atom = NULL)
 {
     //@TODO: enforce singularity
     $bond = new Model_Zupalbonds();
     $bond->to_atom = $pTarget->get_atomic_id();
     $bond->to_model_class = $pTarget->get_model_class();
     $bond->from_atom = $this->get_atomic_id();
     $bond->from_model_class = $this->get_model_class();
     $bond->type = $pType;
     if ($bond_atom) {
         $bond->bond_atom = $bond_atom->get_atomic_id();
     }
     $bond->save();
     return $bond;
 }
Example #2
0
 /**
  *
  * @param id | Model_ZupalatomIF $pTarget
  * @return void
  */
 public function unbond($pTarget, $pType = NULL, Model_ZupalatomIF $bond_atom = NULL)
 {
     $params = array('from_atom' => $this->get_atomic_id(), 'from_model_class' => $this->get_model_class(), 'type' => $pType, 'to_atom' => $pTarget->get_atomic_id());
     if ($bond_atom) {
         $params['bond_atom'] = $bond_atom->get_atomic_id();
     }
     if ($found = Model_Zupalbonds::getInstance()->find($params)) {
         foreach ($found as $bond) {
             $bond->delete();
         }
     }
 }