chore(deps): bump twig/twig from 3.17.1 to 3.19.0 (#7951)
[openemr.git] / interface / product_registration / product_registration_controller.php
blobbba1320c1e7460761ebcfb7ce694e42b8b697e14
1 <?php
3 /**
4 * ProductRegistrationController
6 * LICENSE: This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
17 * @package OpenEMR
18 * @author Matthew Vita <matthewvita48@gmail.com>
19 * @link http://www.open-emr.org
22 $ignoreAuth = true;
23 require_once("../globals.php");
24 require_once($GLOBALS['fileroot'] . "/interface/product_registration/exceptions/generic_product_registration_exception.php");
26 use OpenEMR\Common\Http\HttpResponseHelper;
27 use OpenEMR\Services\ProductRegistrationService;
29 class ProductRegistrationController
31 private $productRegistrationService;
33 public function __construct()
35 $this->productRegistrationService = new ProductRegistrationService();
37 // (note this is here until we use Zend Framework)
38 switch ($_SERVER['REQUEST_METHOD']) {
39 case 'POST':
40 $this->post();
41 break;
42 case 'GET':
43 $this->get();
44 break;
48 public function get()
50 $statusPayload = $this->productRegistrationService->getProductStatus();
52 HttpResponseHelper::send(200, $statusPayload, 'JSON');
55 public function post()
57 $response = null;
58 $status = 500;
60 try {
61 $response = [];
62 $registrationEmail = $this->productRegistrationService->registerProduct($_POST['email']);
63 $response['email'] = $registrationEmail;
64 $status = 201;
65 } catch (GenericProductRegistrationException $genericProductRegistrationException) {
66 $response = $genericProductRegistrationException->errorMessage();
69 HttpResponseHelper::send($status, $response, 'JSON');
73 // Initialize self (note this is here until we use Zend Framework)
74 $productRegistrationController = new ProductRegistrationController();