Pimcore\Model\Tool\Targeting\Rule\Dao::getByName PHP Method

getByName() public method

public getByName ( string $name = null )
$name string
    public function getByName($name = null)
    {
        if ($name != null) {
            $this->model->setName($name);
        }
        $data = $this->db->fetchAll("SELECT id FROM targeting_rules WHERE name = ?", $this->model->getName());
        if (count($data) === 1) {
            $this->getById($data[0]["id"]);
        } else {
            throw new \Exception("target with name " . $this->model->getId() . " doesn't exist or isn't unique");
        }
    }