Add static content endpoint for customer app #799

This commit is contained in:
Ramon Gutierrez 2024-04-27 01:44:39 +08:00
parent b19d9c203a
commit d9d4ffbecf
2 changed files with 41 additions and 1 deletions

View file

@ -312,4 +312,10 @@ apiv2_insurance_premiums_banner:
apiv2_insurance_body_types:
path: /apiv2/insurance/body_types
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]

View 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,
]);
}
}