public function getBySourceId($id = null, $type = null)
{
if ($id && $type) {
$this->model->setSourceId($id);
$this->model->setSourceType($id);
}
// requires
$data = $this->db->fetchAll("SELECT * FROM dependencies WHERE sourceid = ? AND sourcetype = ?", [$this->model->getSourceId(), $this->model->getSourceType()]);
if (is_array($data) && count($data) > 0) {
foreach ($data as $d) {
$this->model->addRequirement($d["targetid"], $d["targettype"]);
}
}
// required by
$data = [];
$data = $this->db->fetchAll("SELECT * FROM dependencies WHERE targetid = ? AND targettype = ?", [$this->model->getSourceId(), $this->model->getSourceType()]);
if (is_array($data) && count($data) > 0) {
foreach ($data as $d) {
$this->model->requiredBy[] = ["id" => $d["sourceid"], "type" => $d["sourcetype"]];
}
}
}