szurubooru/src/Dao/UserDao.php

38 lines
1 KiB
PHP
Raw Normal View History

<?php
namespace Szurubooru\Dao;
class UserDao extends AbstractDao implements ICrudDao
{
public function __construct(
\Szurubooru\DatabaseConnection $databaseConnection)
{
parent::__construct($databaseConnection, 'users', '\Szurubooru\Entities\User');
}
public function getByName($userName)
{
$arrayEntity = $this->collection->findOne(['name' => $userName]);
return $this->entityConverter->toEntity($arrayEntity);
}
2014-09-01 19:43:49 +02:00
public function getByEmail($userEmail, $allowUnconfirmed = false)
{
$arrayEntity = $this->collection->findOne(['email' => $userEmail]);
if (!$arrayEntity and $allowUnconfirmed)
$arrayEntity = $this->collection->findOne(['emailUnconfirmed' => $userEmail]);
return $this->entityConverter->toEntity($arrayEntity);
}
2014-09-01 19:43:49 +02:00
public function hasAnyUsers()
{
return (bool) $this->collection->findOne();
}
2014-09-05 13:50:51 +02:00
public function deleteByName($userName)
{
$this->collection->remove(['name' => $userName]);
$tokens = $this->db->selectCollection('tokens');
$tokens->remove(['additionalData' => $userName]);
}
}