Pimcore\Model\User\AbstractUser\Dao::getByName PHP Метод

getByName() публичный Метод

public getByName ( $name )
$name
    public function getByName($name)
    {
        try {
            $data = $this->db->fetchRow("SELECT * FROM users WHERE `type` = ? AND `name` = ?", [$this->model->getType(), $name]);
            if ($data["id"]) {
                $this->assignVariablesToModel($data);
            } else {
                throw new \Exception("user doesn't exist");
            }
        } catch (\Exception $e) {
            throw $e;
        }
    }

Usage Example

Пример #1
0
 /**
  * @param $name
  * @throws \Exception
  */
 public function getByName($name)
 {
     parent::getByName($name);
     if (in_array($this->model->getType(), ["user", "role"])) {
         $this->loadWorkspaces();
     }
 }