Add pool interfaces, refactor imports in the bootstrap, re-organize some of the APIs

This commit is contained in:
Dave Smith-Hayes 2024-07-25 20:32:26 -04:00
parent 7f05554f4e
commit e58c442ccf
7 changed files with 34 additions and 41 deletions

View File

@ -2,41 +2,33 @@
namespace Slovocast;
use Exception;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Slim\App;
use Slim\Factory\AppFactory;
use League\Config\Configuration;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use DI\Container;
use DI\ContainerBuilder;
use Slim\Psr7\Factory\ResponseFactory;
use Slovocast\Configuration\SiteInformationSchema;
use Slovocast\Configuration\DatabaseConnectionSchema;
use Slovocast\Configuration\SessionSchema;
use Twig\Error\LoaderError;
use Slovocast\Domain\Repository\User\UserRepositoryInterface;
use Slovocast\Domain\Repository\User\UserRepository;
use Slovocast\Infrastructure\User\UserAuthorizationInterface;
use Slovocast\Infrastructure\User\BasicUserAuthorization;
use React\Mysql\MysqlClient;
use Psr\Log\LoggerInterface;
use Monolog\Logger;
use Exception;
use League\Config\Configuration;
use Monolog\Handler\StreamHandler;
use Monolog\Level;
use Monolog\Logger;
use Odan\Session\PhpSession;
use Odan\Session\SessionInterface;
use Odan\Session\SessionManagerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Log\LoggerInterface;
use React\Mysql\MysqlClient;
use Slim\App;
use Slim\Factory\AppFactory;
use Slim\Psr7\Factory\ResponseFactory;
use Slovocast\Configuration\DatabaseConnectionSchema;
use Slovocast\Configuration\SessionSchema;
use Slovocast\Configuration\SiteInformationSchema;
use Slovocast\Domain\Repository\User\UserRepository;
use Slovocast\Domain\Repository\User\UserRepositoryInterface;
use Slovocast\Infrastructure\Api\User\UserAuthorizationInterface;
use Slovocast\Infrastructure\User\BasicUserAuthorization;
use Twig\Error\LoaderError;
/**
* Defines here are used globally

View File

@ -2,12 +2,12 @@
namespace Slovocast\Controller\User;
use Odan\Session\SessionInterface;
use Psr\Http\Message\ResponseInterface as Response;
use Slovocast\Controller\Controller;
use Slovocast\Domain\Repository\User\UserRepositoryInterface;
use Slovocast\Infrastructure\User\UserAuthorizationInterface;
use Slovocast\Exception\EntityNotFoundException;
use Psr\Http\Message\ResponseInterface as Response;
use Odan\Session\SessionInterface;
use Slovocast\Infrastructure\Api\User\UserAuthorizationInterface;
class LoginUserAction extends Controller
{
@ -34,7 +34,7 @@ class LoginUserAction extends Controller
}
// start the session
$this->session->set('user', [
$this->session->set('user', [
'id' => $user->getId(),
'authenticated' => true
]);

View File

@ -2,11 +2,11 @@
namespace Slovocast\Domain\Repository\User;
use function React\Async\await;
use React\Mysql\MysqlClient;
use Slovocast\Infrastructure\User\UserAuthorizationInterface;
use Slovocast\Exception\EntityNotFoundException;
use Slovocast\Domain\Entity\User;
use Slovocast\Exception\EntityNotFoundException;
use Slovocast\Infrastructure\Api\User\UserAuthorizationInterface;
use function React\Async\await;
class UserRepository implements UserRepositoryInterface
{

View File

@ -2,7 +2,7 @@
namespace Slovocast\Infrastructure\Api\Database;
interface ConnectionInterface
interface PooledConnectionInterface
{
public function release(): void;
}

View File

@ -4,7 +4,8 @@ namespace Slovocast\Infrastructure\Api\Database;
interface ConnectionPoolInterface
{
public function getTotalConnectionCount(): int;
public function getFreeConnectionsCount(): int;
public function getActiveConnectionsCount(): int;
public function hasFreeConnection(): bool;
public function getConnection(): ConnectionInterface;
public function releaseConnection(ConnectionInterface $connection): void;

View File

@ -1,11 +1,11 @@
<?php
namespace Slovocast\Infrastructure\User;
namespace Slovocast\Infrastructure\Api\User;
/**
* A simple interface for securing and checking secured passwords for a user
*/
interface UserAuthorizationInterface
interface UserAuthorizationInterface
{
public function hash(string $password): string;
public function verify(string $password, string $hash): bool;

View File

@ -2,7 +2,7 @@
namespace Slovocast\Infrastructure\User;
use Slovocast\Infrastructure\User\UserAuthorizationInterface;
use Slovocast\Infrastructure\Api\User\UserAuthorizationInterface;
/**
* This empty class will essentially just check hashed passwords passed into it
@ -15,7 +15,7 @@ class BasicUserAuthorization implements UserAuthorizationInterface
return password_hash($password, PASSWORD_BCRYPT);
}
public function verify(string $password, string $hash): bool
public function verify(string $password, string $hash): bool
{
return password_verify($password, $hash);
}