Eine fehlende Datenbank löst schon in der Erstellung des Objektes einen Fehler aus.
This commit is contained in:
@@ -4,6 +4,7 @@ namespace TorstenHettstedt\TimekeepingApi\Controller;
|
|||||||
|
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use PDO;
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
use Slim\Psr7\Request;
|
use Slim\Psr7\Request;
|
||||||
use Slim\Psr7\Response;
|
use Slim\Psr7\Response;
|
||||||
@@ -14,13 +15,26 @@ use TorstenHettstedt\TimekeepingApi\Repositories\WorkingHoursYearlyViewRepositor
|
|||||||
|
|
||||||
class WorkingHoursViewController
|
class WorkingHoursViewController
|
||||||
{
|
{
|
||||||
|
protected PDO $databases;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ContainerInterface
|
* @var ContainerInterface
|
||||||
*/
|
*/
|
||||||
protected ContainerInterface $container;
|
protected ContainerInterface $container;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WorkingHoursViewController constructor.
|
||||||
|
*
|
||||||
|
* @param ContainerInterface $container
|
||||||
|
*
|
||||||
|
* @throws NotDatabasesException
|
||||||
|
*/
|
||||||
public function __construct(ContainerInterface $container) {
|
public function __construct(ContainerInterface $container) {
|
||||||
$this->container = $container;
|
$this->container = $container;
|
||||||
|
if ($container->has('databases') === false) {
|
||||||
|
throw new NotDatabasesException('Datenbank ist nicht Vorhanden');
|
||||||
|
}
|
||||||
|
$this->databases = $container->get('databases');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,14 +45,10 @@ class WorkingHoursViewController
|
|||||||
* @return Response
|
* @return Response
|
||||||
*
|
*
|
||||||
* @noinspection PhpUnusedParameterInspection
|
* @noinspection PhpUnusedParameterInspection
|
||||||
* @throws NotDatabasesException
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function browseWeekly(Request $request, Response $response, array $args): Response
|
public function browseWeekly(Request $request, Response $response, array $args): Response
|
||||||
{
|
{
|
||||||
if ($this->container->has('databases') === false) {
|
|
||||||
throw new NotDatabasesException('Datenbank ist nicht Vorhanden');
|
|
||||||
}
|
|
||||||
$repository = new WorkingHoursWeeklyViewRepository($this->container->get('databases'));
|
$repository = new WorkingHoursWeeklyViewRepository($this->container->get('databases'));
|
||||||
return $this->printResponse($response, $repository->findAll());
|
return $this->printResponse($response, $repository->findAll());
|
||||||
}
|
}
|
||||||
@@ -55,9 +65,6 @@ class WorkingHoursViewController
|
|||||||
*/
|
*/
|
||||||
public function browseMonthly(Request $request, Response $response, array $args): Response
|
public function browseMonthly(Request $request, Response $response, array $args): Response
|
||||||
{
|
{
|
||||||
if ($this->container->has('databases') === false) {
|
|
||||||
throw new NotDatabasesException('Datenbank ist nicht Vorhanden');
|
|
||||||
}
|
|
||||||
$repository = new WorkingHoursMonthlyViewRepository($this->container->get('databases'));
|
$repository = new WorkingHoursMonthlyViewRepository($this->container->get('databases'));
|
||||||
return $this->printResponse($response, $repository->findAll());
|
return $this->printResponse($response, $repository->findAll());
|
||||||
}
|
}
|
||||||
@@ -74,9 +81,6 @@ class WorkingHoursViewController
|
|||||||
*/
|
*/
|
||||||
public function browseYearly(Request $request, Response $response, array $args): Response
|
public function browseYearly(Request $request, Response $response, array $args): Response
|
||||||
{
|
{
|
||||||
if ($this->container->has('databases') === false) {
|
|
||||||
throw new NotDatabasesException('Datenbank ist nicht Vorhanden');
|
|
||||||
}
|
|
||||||
$repository = new WorkingHoursYearlyViewRepository($this->container->get('databases'));
|
$repository = new WorkingHoursYearlyViewRepository($this->container->get('databases'));
|
||||||
return $this->printResponse($response, $repository->findAll());
|
return $this->printResponse($response, $repository->findAll());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user