Reflection turned out to be bad, since I cannot implement my own method in entities, like Post::setUser() instead of Post::setUserId().
39 lines
876 B
PHP
39 lines
876 B
PHP
<?php
|
|
namespace Szurubooru\Dao;
|
|
|
|
class UserDao extends AbstractDao implements ICrudDao
|
|
{
|
|
public function __construct(\Szurubooru\DatabaseConnection $databaseConnection)
|
|
{
|
|
parent::__construct(
|
|
$databaseConnection,
|
|
'users',
|
|
new \Szurubooru\Dao\EntityConverters\UserEntityConverter());
|
|
}
|
|
|
|
public function findByName($userName)
|
|
{
|
|
return $this->findOneBy('name', $userName);
|
|
}
|
|
|
|
public function findByEmail($userEmail, $allowUnconfirmed = false)
|
|
{
|
|
$result = $this->findOneBy('email', $userEmail);
|
|
if (!$result and $allowUnconfirmed)
|
|
{
|
|
$result = $this->findOneBy('emailUnconfirmed', $userEmail);
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
public function hasAnyUsers()
|
|
{
|
|
return $this->hasAnyRecords();
|
|
}
|
|
|
|
public function deleteByName($userName)
|
|
{
|
|
$this->deleteBy('name', $userName);
|
|
$this->fpdo->deleteFrom('tokens')->where('additionalData', $userName);
|
|
}
|
|
}
|