Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"ext-json": "*",
"ext-mbstring": "*",
"ext-pdo": "*",
"doctrine/annotations": "^1.0",
"doctrine/doctrine-bundle": "^2.2",
"doctrine/doctrine-fixtures-bundle": "^3.3",
"doctrine/doctrine-migrations-bundle": "^2.0",
Expand All @@ -25,6 +26,7 @@
"jms/i18n-routing-bundle": "@stable",
"nelmio/api-doc-bundle": "^3.6",
"nelmio/cors-bundle": "^2.1",
"phpdocumentor/reflection-docblock": "^5.2",
"ramsey/uuid-doctrine": "^1.5",
"sensio/framework-extra-bundle": "^5.0.0",
"sensiolabs/security-checker": "^6.0",
Expand All @@ -37,6 +39,9 @@
"symfony/monolog-bundle": "3.6.*",
"symfony/polyfill-apcu": "^1.0",
"symfony/polyfill-mbstring": "^1.14.0",
"symfony/property-access": "4.4.*",
"symfony/property-info": "4.4.*",
"symfony/serializer": "4.4.*",
"symfony/swiftmailer-bundle": "^3.3.1",
"symfony/templating": "^4",
"symfony/yaml": "^5.1",
Expand Down
7 changes: 4 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions src/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
use App\Entity\DecklistInterface;
use App\Entity\Pack;
use App\Entity\PackInterface;
use App\Entity\Restriction;
use App\Services\CardsData;
use DateInterval;
use DateTime;
use Doctrine\Common\Collections\Criteria;
use Exception;
use Nelmio\ApiDocBundle\Annotation\Operation;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Swagger\Annotations as SWG;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -23,6 +26,7 @@
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Serializer\SerializerInterface;

/**
* @package App\Controller
Expand Down Expand Up @@ -601,4 +605,41 @@ public function listDecklistsByDateAction($date, Request $request, int $cacheExp
$response->setContent($content);
return $response;
}

/**
* @Route("/api/public/restrictions/", name="api_restrictions", methods={"GET"}, options={"i18n" = false})
*
* Get the description of all the restricted lists as an array of JSON objects.
*
* @Operation(
* tags={"Public"},
* summary="EXPERIMENTAL - DO NOT USE IN PRODUCTION. All the restricted lists.",
* @SWG\Response(
* response="200",
* description="Returned when successful"
* )
* )
*
* @param Request $request
* @param int $cacheExpiration
* @param SerializerInterface $serializer
* @return Response
*/
public function listRestrictions(Request $request, int $cacheExpiration, SerializerInterface $serializer): Response
{
$response = new Response();
$response->setPublic();
$response->setMaxAge($cacheExpiration);
$response->headers->add(array(
'Access-Control-Allow-Origin' => '*',
'Content-Language' => $request->getLocale()
));

$repo = $this->getDoctrine()->getRepository(Restriction::class);
$restrictions = $repo->findAll();
$json = $serializer->serialize($restrictions, 'json');
$response->headers->set('Content-Type', 'application/json');
$response->setContent($json);
return $response;
}
}
3 changes: 3 additions & 0 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@
"config/packages/security.yaml"
]
},
"symfony/serializer-pack": {
"version": "v1.0.4"
},
"symfony/string": {
"version": "v5.1.8"
},
Expand Down