Add static content endpoint for customer app #799
This commit is contained in:
parent
b19d9c203a
commit
d9d4ffbecf
2 changed files with 41 additions and 1 deletions
|
|
@ -313,3 +313,9 @@ apiv2_insurance_body_types:
|
||||||
path: /apiv2/insurance/body_types
|
path: /apiv2/insurance/body_types
|
||||||
controller: App\Controller\CustomerAppAPI\InsuranceController::getBodyTypes
|
controller: App\Controller\CustomerAppAPI\InsuranceController::getBodyTypes
|
||||||
methods: [GET]
|
methods: [GET]
|
||||||
|
|
||||||
|
# static content
|
||||||
|
apiv2_static_content:
|
||||||
|
path: /apiv2/static_content/{id}
|
||||||
|
controller: App\Controller\CustomerAppAPI\StaticContentController::getContent
|
||||||
|
methods: [GET]
|
||||||
|
|
|
||||||
34
src/Controller/CustomerAppAPI/StaticContentController.php
Normal file
34
src/Controller/CustomerAppAPI/StaticContentController.php
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller\CustomerAppAPI;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Catalyst\ApiBundle\Component\Response as ApiResponse;
|
||||||
|
|
||||||
|
use App\Entity\StaticContent;
|
||||||
|
|
||||||
|
class StaticContentController extends ApiController
|
||||||
|
{
|
||||||
|
public function getContent(Request $req, $id)
|
||||||
|
{
|
||||||
|
// check requirements
|
||||||
|
$validity = $this->validateRequest($req);
|
||||||
|
|
||||||
|
if (!$validity['is_valid']) {
|
||||||
|
return new ApiResponse(false, $validity['error']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get content
|
||||||
|
$content = $this->em->getRepository(Staticcontent::class)->find($id);
|
||||||
|
|
||||||
|
// check if it exists
|
||||||
|
if ($content == null) {
|
||||||
|
return new ApiResponse(false, 'Requested content does not exist.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// response
|
||||||
|
return new ApiResponse(true, '', [
|
||||||
|
'content' => $content->content,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue