/** * Clear all relations in the database * @param Element_Interface $element */ public function clearAllForElement($element) { try { $id = $element->getId(); $type = Element_Service::getElementType($element); //schedule for sanity check $data = $this->db->fetchAll("SELECT * FROM dependencies WHERE targetid = ? AND targettype = ?", array($id, $type)); if (is_array($data)) { foreach ($data as $row) { $sanityCheck = new Element_Sanitycheck(); $sanityCheck->setId($row['sourceid']); $sanityCheck->setType($row['sourcetype']); $sanityCheck->save(); } } $this->db->delete("dependencies", $this->db->quoteInto("sourceid = ?", $id) . " AND " . $this->db->quoteInto("sourcetype = ?", $type)); $this->db->delete("dependencies", $this->db->quoteInto("targetid = ?", $id) . " AND " . $this->db->quoteInto("targettype = ?", $type)); } catch (Exception $e) { Logger::error($e); } }
/** * Schedules element with this id for sanity check to be cleaned of broken relations * * @static * @param Element_Interface $element * @return void */ public static function scheduleForSanityCheck($element) { $type = self::getElementType($element); $sanityCheck = new Element_Sanitycheck($element->getId(), $type); $sanityCheck->save(); }