Pimcore\Model\Dependency\Dao::getBySourceId PHP Method

getBySourceId() public method

Loads the relations for the given sourceId and type
public getBySourceId ( integer $id = null, string $type = null ) : void
$id integer
$type string
return void
    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"]];
            }
        }
    }