api-erstellen #1

Merged
TorstenHettstedt merged 52 commits from api-erstellen into master 2021-04-07 13:00:46 +02:00
Showing only changes of commit 2b31e17e14 - Show all commits
@@ -4,6 +4,7 @@ namespace TorstenHettstedt\TimekeepingApi\Controller;
use Exception;
use PDO;
use Psr\Container\ContainerInterface;
use Slim\Psr7\Request;
use Slim\Psr7\Response;
@@ -14,13 +15,26 @@ use TorstenHettstedt\TimekeepingApi\Repositories\WorkingHoursYearlyViewRepositor
class WorkingHoursViewController
{
protected PDO $databases;
/**
* @var ContainerInterface
*/
protected ContainerInterface $container;
/**
* WorkingHoursViewController constructor.
*
* @param ContainerInterface $container
*
* @throws NotDatabasesException
*/
public function __construct(ContainerInterface $container) {
$this->container = $container;
if ($container->has('databases') === false) {
throw new NotDatabasesException('Datenbank ist nicht Vorhanden');
TorstenHettstedt marked this conversation as resolved Outdated
Outdated
Review

Das Verhalten ist in WorkingHoursController besser gelöst.

Das Verhalten ist in `WorkingHoursController` besser gelöst.
}
$this->databases = $container->get('databases');
}
TorstenHettstedt marked this conversation as resolved Outdated
Outdated
Review

Das kann ähnlich dem WorkingHoursController in den Konstruktor.

Das kann ähnlich dem `WorkingHoursController` in den Konstruktor.
/**
@@ -31,14 +45,10 @@ class WorkingHoursViewController
* @return Response
*
* @noinspection PhpUnusedParameterInspection
* @throws NotDatabasesException
* @throws Exception
*/
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'));
return $this->printResponse($response, $repository->findAll());
}
TorstenHettstedt marked this conversation as resolved Outdated
Outdated
Review

Das Verhalten ist in WorkingHoursController besser gelöst.

Das Verhalten ist in `WorkingHoursController` besser gelöst.
@@ -55,9 +65,6 @@ class WorkingHoursViewController
*/
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'));
return $this->printResponse($response, $repository->findAll());
}
1
@@ -74,9 +81,6 @@ class WorkingHoursViewController
*/
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'));
return $this->printResponse($response, $repository->findAll());
}
1