/** Breaks links to all previously linked $example. * $example can be either a string of the classname, or an instance of the class itself * If $relation is provided, only matched relations will be delinked */ function deLinkAll($example, $relation = NULL) { if (is_string($example)) { $subject = new $example(); } else { $subject = $example; } $link = new AmortizeLink($this, $subject); return $link->breakLink($this->getPrimary(), NULL, $relation); }
protected function getLinkedObjects($example, $params = NULL, $relation = NULL, $backLinks = FALSE, $wherelike = NULL, $ordering = NULL) { $example = is_object($example) ? get_class($example) : $example; $prototype = new $example(); $id = $this->getPrimary(); if (!$backLinks) { $linkObject = new AmortizeLink($this, $prototype); $data = $linkObject->getLinksFromID($id, $params, $relation, $wherelike, $ordering); } else { $linkObject = new AmortizeLink($prototype, $this); $data = $linkObject->getBackLinksFromID($id, $params, $relation, $wherelike, $ordering); } $data = is_array($data) ? $data : array(); $results = array(); foreach ($data as $fields) { $temp = clone $prototype; $temp->setAttribs($fields, TRUE); $results[] = $temp; } return $results; }