forked from mapasculturais/mapasculturais
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adiciona versão mais recente mapacultural ce
- Loading branch information
Showing
72 changed files
with
2,076 additions
and
623 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
APP_ENV= |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
vendor/ | ||
vendor/ | ||
.env |
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
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
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,70 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use App\Repository\AgentRepository; | ||
use App\Repository\EventRepository; | ||
use App\Repository\Interface\AgentRepositoryInterface; | ||
use App\Repository\Interface\EventRepositoryInterface; | ||
use App\Repository\Interface\OpportunityRepositoryInterface; | ||
use App\Repository\Interface\ProjectRepositoryInterface; | ||
use App\Repository\Interface\SealRepositoryInterface; | ||
use App\Repository\Interface\SpaceRepositoryInterface; | ||
use App\Repository\Interface\TermRepositoryInterface; | ||
use App\Repository\OpportunityRepository; | ||
use App\Repository\ProjectRepository; | ||
use App\Repository\SealRepository; | ||
use App\Repository\SpaceRepository; | ||
use App\Repository\TermRepository; | ||
use App\Service\AgentService; | ||
use App\Service\EventService; | ||
use App\Service\Interface\AgentServiceInterface; | ||
use App\Service\Interface\EventServiceInterface; | ||
use App\Service\Interface\OpportunityServiceInterface; | ||
use App\Service\Interface\ProjectServiceInterface; | ||
use App\Service\Interface\SealServiceInterface; | ||
use App\Service\Interface\SpaceServiceInterface; | ||
use App\Service\Interface\TermServiceInterface; | ||
use App\Service\OpportunityService; | ||
use App\Service\ProjectService; | ||
use App\Service\SealService; | ||
use App\Service\SpaceService; | ||
use App\Service\TermService; | ||
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; | ||
use Symfony\Component\Serializer\Serializer; | ||
use Symfony\Component\Serializer\SerializerInterface; | ||
use Symfony\Component\Validator\Validation; | ||
use Symfony\Component\Validator\Validator\ValidatorInterface; | ||
|
||
return [ | ||
SerializerInterface::class => fn () => new Serializer([new ObjectNormalizer()]), | ||
ValidatorInterface::class => fn () => Validation::createValidatorBuilder()->enableAttributeMapping()->getValidator(), | ||
...repositories(), | ||
...services(), | ||
]; | ||
|
||
function repositories(): array | ||
{ | ||
return [ | ||
AgentRepositoryInterface::class => fn () => new AgentRepository(), | ||
EventRepositoryInterface::class => fn () => new EventRepository(), | ||
OpportunityRepositoryInterface::class => fn () => new OpportunityRepository(), | ||
ProjectRepositoryInterface::class => fn () => new ProjectRepository(), | ||
SealRepositoryInterface::class => fn () => new SealRepository(), | ||
SpaceRepositoryInterface::class => fn () => new SpaceRepository(), | ||
TermRepositoryInterface::class => fn () => new TermRepository(), | ||
]; | ||
} | ||
|
||
function services(): array | ||
{ | ||
return [ | ||
AgentServiceInterface::class => fn () => new AgentService(new AgentRepository(), new Serializer([new ObjectNormalizer()])), | ||
EventServiceInterface::class => fn () => new EventService(new EventRepository(), new Serializer([new ObjectNormalizer()])), | ||
OpportunityServiceInterface::class => fn () => new OpportunityService(new OpportunityRepository(), new Serializer([new ObjectNormalizer()])), | ||
ProjectServiceInterface::class => fn () => new ProjectService(new ProjectRepository(), new Serializer([new ObjectNormalizer()])), | ||
SealServiceInterface::class => fn () => new SealService(new AgentRepository(), new SealRepository(), new Serializer([new ObjectNormalizer()])), | ||
SpaceServiceInterface::class => fn () => new SpaceService(new Serializer([new ObjectNormalizer()]), new SpaceRepository()), | ||
TermServiceInterface::class => fn () => new TermService(new Serializer([new ObjectNormalizer()]), new TermRepository()), | ||
]; | ||
} |
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
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
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
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
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
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
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
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\Application; | ||
|
||
use Symfony\Component\Dotenv\Dotenv; | ||
|
||
class Environment | ||
{ | ||
private const LOCAL = 'local'; | ||
|
||
public static function getEnvinronment(): string | ||
{ | ||
$env = self::getEnvData(); | ||
|
||
if (false === file_exists($env) || false === isset($_ENV['APP_ENV'])) { | ||
exit('Please create correctly a .env file in the root directory (/app/.env)'.PHP_EOL); | ||
} | ||
|
||
return $_ENV['APP_ENV']; | ||
} | ||
|
||
public static function getEnvData(): mixed | ||
{ | ||
return dirname(__DIR__, 2).'/.env'; | ||
} | ||
|
||
public static function isLocal(): bool | ||
{ | ||
$dotenv = new Dotenv(); | ||
$dotenv->load(self::getEnvData()); | ||
|
||
return self::LOCAL === self::getEnvinronment(); | ||
} | ||
} |
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
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
19 changes: 19 additions & 0 deletions
19
api/mapas/app/src/Controller/Api/AbstractApiController.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,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Controller\Api; | ||
|
||
use App\Exception\RequiredIdParamException; | ||
|
||
abstract class AbstractApiController | ||
{ | ||
public function extractIdParam(array $params): int | ||
{ | ||
if (false === isset($params['id'])) { | ||
throw new RequiredIdParamException(); | ||
} | ||
|
||
return (int) $params['id']; | ||
} | ||
} |
Oops, something went wrong.