Use __DIR__ to make importing easier and only when required
This commit is contained in:
parent
d1ae2a8009
commit
4942fdbfda
18
api/businesslogic/ValidationException.php
Normal file
18
api/businesslogic/ValidationException.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ValidationException extends Exception {
|
||||||
|
public $validationModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ValidationException constructor.
|
||||||
|
* @param ValidationModel $validationModel The validatio model
|
||||||
|
* @throws Exception If the validationModel's errorKeys is empty
|
||||||
|
*/
|
||||||
|
function __construct($validationModel) {
|
||||||
|
if (count($validationModel->errorKeys) === 0) {
|
||||||
|
throw new Exception('Tried to throw a ValidationException, but the validation model was valid!');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->validationModel = $validationModel;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class CreateTicketForCustomerModel {
|
class CreateTicketByCustomerModel {
|
||||||
// Metadata
|
// Metadata
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
@ -1,19 +1,31 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $ticket_request CreateTicketForCustomerModel
|
* @param $ticket_request CreateTicketByCustomerModel
|
||||||
|
* @param $hesk_settings array HESK settings
|
||||||
|
* @param $modsForHesk_settings array Mods for HESK settings
|
||||||
|
* @throws ValidationException When a required field in $ticket_request is missing
|
||||||
*/
|
*/
|
||||||
function create_ticket_for_customer($ticket_request, $hesk_settings, $modsForHesk_settings) {
|
function createTicketByCustomer($ticket_request, $hesk_settings, $modsForHesk_settings) {
|
||||||
validate($ticket_request, false, $hesk_settings, $modsForHesk_settings);
|
$validationModel = validate($ticket_request, false, $hesk_settings, $modsForHesk_settings);
|
||||||
|
|
||||||
|
if (count($validationModel->errorKeys) > 0) {
|
||||||
|
require_once(__DIR__ . '/../ValidationException.php');
|
||||||
|
|
||||||
|
// Validation failed
|
||||||
|
throw new ValidationException($validationModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the ticket
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $ticket_request CreateTicketForCustomerModel
|
* @param $ticket_request CreateTicketByCustomerModel
|
||||||
* @param $staff bool
|
* @param $staff bool
|
||||||
* @return ValidationModel If errorKeys is empty, validation successful. Otherwise invalid ticket
|
* @return ValidationModel If errorKeys is empty, validation successful. Otherwise invalid ticket
|
||||||
*/
|
*/
|
||||||
function validate($ticket_request, $staff, $hesk_settings, $modsForHesk_settings) {
|
function validate($ticket_request, $staff, $hesk_settings, $modsForHesk_settings) {
|
||||||
require_once('../email_validators.php');
|
require_once(__DIR__ . '/../email_validators.php');
|
||||||
//require_once('../category/retriever.php');
|
//require_once('../category/retriever.php');
|
||||||
//require_once('../bans/retriever.php');
|
//require_once('../bans/retriever.php');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user