public function homeAction() { $this->view->page = $page = new Pages_Model_Zupalpages(1); $aid = $page->get_atomic_id(); $m = Model_Zupalbonds::getInstance(); $this->view->pages = $m->get_bonds_to($aid, 'parent', 'from_atom'); }
/** * * @param boolean $pReload * @return Model_Zupalbonds */ public static function getInstance($pReload = FALSE) { if ($pReload || is_null(self::$_Instance)) { // process self::$_Instance = new self(); } return self::$_Instance; }
/** * * @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; }
/** * * @param int | Model_users $pUser = NULL */ public function add_user($pUser = NULL) { if ($pUser) { $pUser = Zupal_Domain_Abstract::_as($pUser, 'Model_Users'); } else { $pUser = Model_Users::current_user(); } if (!$pUser) { throw new Exception(__METHOD__ . ': user missing'); } $active_bond = Model_Zupalbonds::getInstance()->make_unique_bond(array('bond_atom' => $this->game_type(), 'from_atom' => $pUser, 'type' => self::ACTIVE_KEY)); $active_bond->set_to_atom($this); return $active_bond; }
/** * * @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(); } } }