-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Samuel Xavier
committed
Sep 5, 2019
1 parent
c592ce5
commit 22a02aa
Showing
14 changed files
with
345 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/App/src/Handler/Factory/TipoUsuario/TipoUsuarioAlterarHandlerFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Handler\Factory\TipoUsuario; | ||
|
||
use App\Handler\TipoUsuario\TipoUsuarioAlterarHandler; | ||
use Interop\Container\ContainerInterface; | ||
|
||
/** | ||
* Class TipoUsuarioAlterarHandlerFactory | ||
* @package App\Handler\Factory\TipoUsuario | ||
*/ | ||
class TipoUsuarioAlterarHandlerFactory | ||
{ | ||
/** | ||
* @param ContainerInterface $container | ||
* @return TipoUsuarioAlterarHandler | ||
*/ | ||
public function __invoke(ContainerInterface $container): TipoUsuarioAlterarHandler{ | ||
return new TipoUsuarioAlterarHandler($container); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/App/src/Handler/Factory/TipoUsuario/TipoUsuarioCriarHandlerFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Handler\Factory\TipoUsuario; | ||
|
||
use App\Handler\TipoUsuario\TipoUsuarioCriarHandler; | ||
use Interop\Container\ContainerInterface; | ||
|
||
/** | ||
* Class TipoUsuarioCriarHandlerFactory | ||
* @package App\Handler\Factory\TipoUsuario | ||
*/ | ||
class TipoUsuarioCriarHandlerFactory | ||
{ | ||
/** | ||
* @param ContainerInterface $container | ||
* @return TipoUsuarioCriarHandler | ||
*/ | ||
public function __invoke(ContainerInterface $container): TipoUsuarioCriarHandler | ||
{ | ||
return new TipoUsuarioCriarHandler($container); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/App/src/Handler/Factory/TipoUsuario/TipoUsuarioDeletarHandlerFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Handler\Factory\TipoUsuario; | ||
|
||
use App\Handler\TipoUsuario\TipoUsuarioDeletarHandler; | ||
use Interop\Container\ContainerInterface; | ||
|
||
/** | ||
* Class TipoUsuarioDeletarHandlerFactory | ||
* @package App\Handler\Factory\TipoUsuario | ||
*/ | ||
class TipoUsuarioDeletarHandlerFactory | ||
{ | ||
|
||
/** | ||
* @param ContainerInterface $container | ||
* @return TipoUsuarioDeletarHandler | ||
*/ | ||
public function __invoke(ContainerInterface $container): TipoUsuarioDeletarHandler | ||
{ | ||
return new TipoUsuarioDeletarHandler($container); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/App/src/Handler/Factory/TipoUsuario/TipoUsuarioListarHandlerFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Handler\Factory\TipoUsuario; | ||
|
||
use App\Handler\TipoUsuario\TipoUsuarioListarHandler; | ||
use Interop\Container\ContainerInterface; | ||
|
||
/** | ||
* Class TipoUsuarioListarHandlerFactory | ||
* @package App\Handler\Factory\TipoUsuario | ||
*/ | ||
class TipoUsuarioListarHandlerFactory | ||
{ | ||
/** | ||
* @param ContainerInterface $container | ||
* @return TipoUsuarioListarHandler | ||
*/ | ||
public function __invoke(ContainerInterface $container): TipoUsuarioListarHandler | ||
{ | ||
return new TipoUsuarioListarHandler($container); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/App/src/Handler/Factory/TipoUsuario/TipoUsuarioListarUmHandlerFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Handler\Factory\TipoUsuario; | ||
|
||
use App\Handler\TipoUsuario\TipoUsuarioListarUmHandler; | ||
use Interop\Container\ContainerInterface; | ||
|
||
/** | ||
* Class TipoUsuarioListarUmHandlerFactory | ||
* @package App\Handler\Factory\TipoUsuario | ||
*/ | ||
class TipoUsuarioListarUmHandlerFactory | ||
{ | ||
/** | ||
* @param ContainerInterface $container | ||
* @return TipoUsuarioListarUmHandler | ||
*/ | ||
public function __invoke(ContainerInterface $container): TipoUsuarioListarUmHandler | ||
{ | ||
return new TipoUsuarioListarUmHandler($container); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Handler; | ||
|
||
use Interop\Container\ContainerInterface; | ||
|
||
/** | ||
* Class HandlerAbstract | ||
* @package App\Handler | ||
*/ | ||
abstract class HandlerAbstract | ||
{ | ||
/** | ||
* @var ContainerInterface | ||
*/ | ||
protected $container; | ||
|
||
/** | ||
* * HandlerAbstract constructor. | ||
* @param ContainerInterface $container | ||
*/ | ||
public function __construct(ContainerInterface $container) | ||
{ | ||
$this->container = $container; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/App/src/Handler/TipoUsuario/TipoUsuarioAlterarHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Handler\TipoUsuario; | ||
|
||
use App\Handler\HandlerAbstract; | ||
use App\Service\TipoUsuarioService; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Server\RequestHandlerInterface; | ||
use Zend\Diactoros\Response\JsonResponse; | ||
use Zend\Json\Json; | ||
|
||
/** | ||
* Class TipoUsuarioAlterarHandler | ||
* @package App\Handler\TipoUsuario | ||
*/ | ||
class TipoUsuarioAlterarHandler extends HandlerAbstract implements RequestHandlerInterface | ||
{ | ||
|
||
/** | ||
* @param ServerRequestInterface $request | ||
* @return ResponseInterface | ||
*/ | ||
public function handle(ServerRequestInterface $request): ResponseInterface | ||
{ | ||
$data = Json::decode($request->getBody()->getContents(), JSON_OBJECT_AS_ARRAY); | ||
$data['id'] = (int)$request->getAttribute('id'); | ||
$service = $this->container->get(TipoUsuarioService::class); | ||
$userType = $service->update($data); | ||
|
||
return new JsonResponse([ | ||
'data' => $userType | ||
], 200); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/App/src/Handler/TipoUsuario/TipoUsuarioCriarHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Handler\TipoUsuario; | ||
|
||
use App\Handler\HandlerAbstract; | ||
use App\Service\TipoUsuarioService; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Server\RequestHandlerInterface; | ||
use Zend\Diactoros\Response\JsonResponse; | ||
use Zend\Json\Json; | ||
|
||
/** | ||
* Class TipoUsuarioCriarHandler | ||
* @package App\Handler\TipoUsuario | ||
*/ | ||
class TipoUsuarioCriarHandler extends HandlerAbstract implements RequestHandlerInterface | ||
{ | ||
/** | ||
* @param ServerRequestInterface $request | ||
* @return ResponseInterface | ||
*/ | ||
public function handle(ServerRequestInterface $request): ResponseInterface | ||
{ | ||
$data = Json::decode($request->getBody()->getContents(), JSON_OBJECT_AS_ARRAY); | ||
$service = $this->container->get(TipoUsuarioService::class); | ||
$userType = $service->insert($data); | ||
|
||
return new JsonResponse([ | ||
'data' => $userType | ||
], 200); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/App/src/Handler/TipoUsuario/TipoUsuarioDeletarHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Handler\TipoUsuario; | ||
|
||
use App\Handler\HandlerAbstract; | ||
use App\Service\TipoUsuarioService; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Server\RequestHandlerInterface; | ||
use Zend\Diactoros\Response\JsonResponse; | ||
use Zend\Json\Json; | ||
|
||
/** | ||
* Class TipoUsuarioDeletarHandler | ||
* @package App\Handler\TipoUsuario | ||
*/ | ||
class TipoUsuarioDeletarHandler extends HandlerAbstract implements RequestHandlerInterface | ||
{ | ||
|
||
/** | ||
* @param ServerRequestInterface $request | ||
* @return ResponseInterface | ||
*/ | ||
public function handle(ServerRequestInterface $request): ResponseInterface | ||
{ | ||
$id = (int)$request->getAttribute('id'); | ||
$service = $this->container->get(TipoUsuarioService::class); | ||
$userTypeDeleted = $service->delete($id); | ||
|
||
return new JsonResponse([ | ||
'data' => $userTypeDeleted | ||
], 200); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/App/src/Handler/TipoUsuario/TipoUsuarioListarHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Handler\TipoUsuario; | ||
|
||
use App\Handler\HandlerAbstract; | ||
use App\Service\TipoUsuarioService; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Server\RequestHandlerInterface; | ||
use Zend\Diactoros\Response\JsonResponse; | ||
|
||
/** | ||
* Class TipoUsuarioListarHandler | ||
* @package App\Handler\TipoUsuario | ||
*/ | ||
class TipoUsuarioListarHandler extends HandlerAbstract implements RequestHandlerInterface | ||
{ | ||
|
||
/** | ||
* @param ServerRequestInterface $request | ||
* @return ResponseInterface | ||
*/ | ||
public function handle(ServerRequestInterface $request): ResponseInterface | ||
{ | ||
$service = $this->container->get(TipoUsuarioService::class); | ||
$resultWithDQL = $service->getAll(); | ||
$resultWithoutDQL = $service->getAllWithDQL(); | ||
|
||
return new JsonResponse([ | ||
'result_with_dql' => $resultWithDQL, | ||
'result_without_dql' => $resultWithoutDQL | ||
]); | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
src/App/src/Handler/TipoUsuario/TipoUsuarioListarUmHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Handler\TipoUsuario; | ||
|
||
use App\Handler\HandlerAbstract; | ||
use App\Service\TipoUsuarioService; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Server\RequestHandlerInterface; | ||
use Zend\Diactoros\Response\JsonResponse; | ||
|
||
/** | ||
* Class TipoUsuarioListarUmHandler | ||
* @package App\Handler\TipoUsuario | ||
*/ | ||
class TipoUsuarioListarUmHandler extends HandlerAbstract implements RequestHandlerInterface | ||
{ | ||
|
||
/** | ||
* @param ServerRequestInterface $request | ||
* @return ResponseInterface | ||
*/ | ||
public function handle(ServerRequestInterface $request): ResponseInterface | ||
{ | ||
$id = (int)$request->getAttribute('id'); | ||
$service = $this->container->get(TipoUsuarioService::class); | ||
$resultWithDQL = $service->getOne($id); | ||
$resultWithoutDQL = $service->getOneWithDQL($id); | ||
|
||
if (!empty($resultWithDQL) && !empty($resultWithoutDQL)) | ||
{ | ||
return new JsonResponse([ | ||
'result_with_dql' => $resultWithDQL, | ||
'result_without_dql' => $resultWithoutDQL | ||
], 200); | ||
} | ||
|
||
return new JsonResponse([ | ||
'error' => true, | ||
'message' => 'Nenhum registro encontrado' | ||
], 404); | ||
} | ||
} |