diff --git a/catalyst/api-bundle/Command/TestAPICommand.php b/catalyst/api-bundle/Command/TestAPICommand.php index f76a8285..bf35ce1e 100644 --- a/catalyst/api-bundle/Command/TestAPICommand.php +++ b/catalyst/api-bundle/Command/TestAPICommand.php @@ -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 ); } } diff --git a/config/api_acl.yaml b/config/api_acl.yaml index c3834bf9..39557cf6 100644 --- a/config/api_acl.yaml +++ b/config/api_acl.yaml @@ -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 diff --git a/config/routes/capi.yaml b/config/routes/capi.yaml index 67509914..cf533814 100644 --- a/config/routes/capi.yaml +++ b/config/routes/capi.yaml @@ -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] diff --git a/src/Controller/CAPI/PrivacyPolicyController.php b/src/Controller/CAPI/PrivacyPolicyController.php new file mode 100644 index 00000000..034d12ff --- /dev/null +++ b/src/Controller/CAPI/PrivacyPolicyController.php @@ -0,0 +1,43 @@ +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); + + } +} diff --git a/src/Controller/PrivacyPolicyController.php b/src/Controller/PrivacyPolicyController.php index 70b39278..dd4e8ed8 100644 --- a/src/Controller/PrivacyPolicyController.php +++ b/src/Controller/PrivacyPolicyController.php @@ -205,7 +205,8 @@ class PrivacyPolicyController extends Controller throw $this->createNotFoundException('The item does not exist'); // set and save values - $row->setName($req->request->get('name')); + $row->setName($req->request->get('name')) + ->setContent($req->request->get('content')); // validate $errors = $validator->validate($row);