Add getPrivacyPolicy to third party API. #263
This commit is contained in:
parent
47e098be1c
commit
417bd3c0e1
4 changed files with 60 additions and 0 deletions
|
|
@ -115,5 +115,9 @@ class TestAPICommand extends Command
|
|||
// vehicle
|
||||
$api->get('/capi/vehicle_manufacturers');
|
||||
$api->get('/capi/vehicles');
|
||||
|
||||
// privacy policy
|
||||
$privacy_policy_id = 2;
|
||||
$api->get('/capi/privacy_policy/' . $privacy_policy_id );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,3 +45,8 @@ access_keys:
|
|||
acls:
|
||||
- id: vehicle.list
|
||||
label: List
|
||||
- id: privacypolicy
|
||||
label: Privacy Policy
|
||||
acls:
|
||||
- id: privacypolicy.find
|
||||
label: Find Privacy Policy
|
||||
|
|
|
|||
|
|
@ -127,3 +127,11 @@ capi_cv_register:
|
|||
path: /capi/customer_vehicle
|
||||
controller: App\Controller\CAPI\CustomerVehicle::register
|
||||
methods: [POST]
|
||||
|
||||
# privacy policy
|
||||
|
||||
# get privacy policy by id
|
||||
capi_privacy_policy:
|
||||
path: /capi/privacy_policy/{id}
|
||||
controller: App\Controller\CAPI\PrivacyPolicyController::getPrivacyPolicy
|
||||
methods: [GET]
|
||||
|
|
|
|||
43
src/Controller/CAPI/PrivacyPolicyController.php
Normal file
43
src/Controller/CAPI/PrivacyPolicyController.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\CAPI;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
use Catalyst\APIBundle\Controller\APIController;
|
||||
use Catalyst\APIBundle\Response\APIResponse;
|
||||
|
||||
use App\Entity\PrivacyPolicy;
|
||||
|
||||
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
|
||||
|
||||
// third party API
|
||||
class PrivacyPolicyController extends APIController
|
||||
{
|
||||
protected $acl_gen;
|
||||
|
||||
public function __construct(ACLGenerator $acl_gen)
|
||||
{
|
||||
$this->acl_gen = $acl_gen;
|
||||
}
|
||||
|
||||
public function getPrivacyPolicy($id, EntityManagerInterface $em)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('privacypolicy.find', null, 'No access.');
|
||||
|
||||
$privacy_policy = $em->getRepository(PrivacyPolicy::class)->find($id);
|
||||
|
||||
if ($privacy_policy == null)
|
||||
return new APIResponse(false, 'No privacy policy found with that number.', null, 404);
|
||||
|
||||
$data = [
|
||||
'privacy_policy' => (string) $privacy_policy->getContent(),
|
||||
];
|
||||
|
||||
return new APIResponse(true, 'Privacy policy found.', $data);
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue