Pimcore\Model\Property\Predefined\Dao::getByKey PHP Method

getByKey() public method

public getByKey ( null $key = null )
$key null
    public function getByKey($key = null)
    {
        if ($key != null) {
            $this->model->setKey($key);
        }
        $key = $this->model->getKey();
        $data = $this->db->fetchAll(function ($row) use($key) {
            if ($row["key"] == $key) {
                return true;
            }
            return false;
        });
        if (count($data) && $data[0]["id"]) {
            $this->assignVariablesToModel($data[0]);
        } else {
            throw new \Exception("Route with name: " . $this->model->getName() . " does not exist");
        }
    }