Add a BaseClass/BaseException for 5.4 compatibility

master
Mike Koch 7 years ago
parent 3c4018ace3
commit 016a50878d
No known key found for this signature in database
GPG Key ID: 9BA5D7F8391455ED

@ -0,0 +1,7 @@
<?php
class BaseClass {
static function clazz() {
return get_called_class();
}
}

@ -0,0 +1,7 @@
<?php
class BaseException extends Exception {
static function clazz() {
return get_called_class();
}
}

@ -3,7 +3,7 @@
namespace BusinessLogic\Attachments; namespace BusinessLogic\Attachments;
class Attachment { class Attachment extends \BaseClass {
/* @var $id int */ /* @var $id int */
public $id; public $id;

@ -17,7 +17,7 @@ use DataAccess\Files\FileDeleter;
use DataAccess\Files\FileWriter; use DataAccess\Files\FileWriter;
use DataAccess\Tickets\TicketGateway; use DataAccess\Tickets\TicketGateway;
class AttachmentHandler { class AttachmentHandler extends \BaseClass {
/* @var $ticketGateway TicketGateway */ /* @var $ticketGateway TicketGateway */
private $ticketGateway; private $ticketGateway;

@ -10,7 +10,7 @@ use DataAccess\Attachments\AttachmentGateway;
use DataAccess\Files\FileReader; use DataAccess\Files\FileReader;
use DataAccess\Tickets\TicketGateway; use DataAccess\Tickets\TicketGateway;
class AttachmentRetriever { class AttachmentRetriever extends \BaseClass {
/* @var $attachmentGateway AttachmentGateway */ /* @var $attachmentGateway AttachmentGateway */
private $attachmentGateway; private $attachmentGateway;

@ -3,7 +3,7 @@
namespace BusinessLogic\Attachments; namespace BusinessLogic\Attachments;
class AttachmentType { class AttachmentType extends \BaseClass {
const MESSAGE = 0; const MESSAGE = 0;
const REPLY = 1; const REPLY = 1;
} }

@ -3,7 +3,7 @@
namespace BusinessLogic\Attachments; namespace BusinessLogic\Attachments;
class CreateAttachmentModel { class CreateAttachmentModel extends \BaseClass {
/* @var $savedName string */ /* @var $savedName string */
public $savedName; public $savedName;

@ -2,7 +2,7 @@
namespace BusinessLogic\Categories; namespace BusinessLogic\Categories;
class Category { class Category extends \BaseClass {
/** /**
* @var int The Categories ID * @var int The Categories ID
*/ */

@ -13,7 +13,7 @@ use DataAccess\Categories\CategoryGateway;
use DataAccess\Settings\ModsForHeskSettingsGateway; use DataAccess\Settings\ModsForHeskSettingsGateway;
use DataAccess\Tickets\TicketGateway; use DataAccess\Tickets\TicketGateway;
class CategoryHandler { class CategoryHandler extends \BaseClass {
/* @var $categoryGateway CategoryGateway */ /* @var $categoryGateway CategoryGateway */
private $categoryGateway; private $categoryGateway;

@ -6,7 +6,7 @@ use BusinessLogic\Security\UserContext;
use DataAccess\Categories\CategoryGateway; use DataAccess\Categories\CategoryGateway;
use DataAccess\Settings\ModsForHeskSettingsGateway; use DataAccess\Settings\ModsForHeskSettingsGateway;
class CategoryRetriever { class CategoryRetriever extends \BaseClass {
/** /**
* @var CategoryGateway * @var CategoryGateway
*/ */

@ -3,7 +3,7 @@
namespace BusinessLogic\Emails; namespace BusinessLogic\Emails;
class Addressees { class Addressees extends \BaseClass {
/** /**
* @var $to string[] * @var $to string[]
*/ */

@ -7,7 +7,7 @@ use BusinessLogic\Tickets\Attachment;
use BusinessLogic\Tickets\Ticket; use BusinessLogic\Tickets\Ticket;
use PHPMailer; use PHPMailer;
class BasicEmailSender implements EmailSender { class BasicEmailSender extends \BaseClass implements EmailSender {
function sendEmail($emailBuilder, $heskSettings, $modsForHeskSettings, $sendAsHtml) { function sendEmail($emailBuilder, $heskSettings, $modsForHeskSettings, $sendAsHtml) {
$mailer = new PHPMailer(); $mailer = new PHPMailer();

@ -5,7 +5,7 @@ namespace BusinessLogic\Emails;
use BusinessLogic\Tickets\Attachment; use BusinessLogic\Tickets\Attachment;
class EmailBuilder { class EmailBuilder extends \BaseClass {
/** /**
* @var $to string[] * @var $to string[]
*/ */

@ -5,7 +5,7 @@ namespace BusinessLogic\Emails;
use BusinessLogic\Tickets\Ticket; use BusinessLogic\Tickets\Ticket;
class EmailSenderHelper { class EmailSenderHelper extends \BaseClass {
/** /**
* @var $emailTemplateParser EmailTemplateParser * @var $emailTemplateParser EmailTemplateParser
*/ */

@ -3,7 +3,7 @@
namespace BusinessLogic\Emails; namespace BusinessLogic\Emails;
class EmailTemplate { class EmailTemplate extends \BaseClass {
/** /**
* @var $languageKey string * @var $languageKey string
*/ */

@ -13,7 +13,7 @@ use DataAccess\Categories\CategoryGateway;
use DataAccess\Security\UserGateway; use DataAccess\Security\UserGateway;
use DataAccess\Statuses\StatusGateway; use DataAccess\Statuses\StatusGateway;
class EmailTemplateParser { class EmailTemplateParser extends \BaseClass {
/** /**
* @var $statusGateway StatusGateway * @var $statusGateway StatusGateway

@ -3,7 +3,7 @@
namespace BusinessLogic\Emails; namespace BusinessLogic\Emails;
class EmailTemplateRetriever { class EmailTemplateRetriever extends \BaseClass {
/** /**
* @var $validTemplates EmailTemplate[] * @var $validTemplates EmailTemplate[]
*/ */

@ -7,7 +7,7 @@ use BusinessLogic\Tickets\Attachment;
use BusinessLogic\Tickets\Ticket; use BusinessLogic\Tickets\Ticket;
use Mailgun\Mailgun; use Mailgun\Mailgun;
class MailgunEmailSender implements EmailSender { class MailgunEmailSender extends \BaseClass implements EmailSender {
function sendEmail($emailBuilder, $heskSettings, $modsForHeskSettings, $sendAsHtml) { function sendEmail($emailBuilder, $heskSettings, $modsForHeskSettings, $sendAsHtml) {
$mailgunArray = array(); $mailgunArray = array();

@ -3,7 +3,7 @@
namespace BusinessLogic\Emails; namespace BusinessLogic\Emails;
class ParsedEmailProperties { class ParsedEmailProperties extends \BaseClass {
function __construct($subject, $message, $htmlMessage) { function __construct($subject, $message, $htmlMessage) {
$this->subject = $subject; $this->subject = $subject;
$this->message = $message; $this->message = $message;

@ -5,7 +5,7 @@ namespace BusinessLogic\Exceptions;
use Exception; use Exception;
class ApiFriendlyException extends Exception { class ApiFriendlyException extends \BaseException {
public $title; public $title;
public $httpResponseCode; public $httpResponseCode;

@ -3,7 +3,7 @@
namespace BusinessLogic; namespace BusinessLogic;
class Helpers { class Helpers extends \BaseClass {
static function getHeader($key) { static function getHeader($key) {
$headers = getallheaders(); $headers = getallheaders();

@ -3,7 +3,7 @@
namespace BusinessLogic\Navigation; namespace BusinessLogic\Navigation;
class CustomNavElement { class CustomNavElement extends \BaseClass {
/* @var $id int*/ /* @var $id int*/
public $id; public $id;

@ -6,7 +6,7 @@ namespace BusinessLogic\Navigation;
use BusinessLogic\Exceptions\ApiFriendlyException; use BusinessLogic\Exceptions\ApiFriendlyException;
use DataAccess\Navigation\CustomNavElementGateway; use DataAccess\Navigation\CustomNavElementGateway;
class CustomNavElementHandler { class CustomNavElementHandler extends \BaseClass {
/* @var $customNavElementGateway CustomNavElementGateway */ /* @var $customNavElementGateway CustomNavElementGateway */
private $customNavElementGateway; private $customNavElementGateway;

@ -3,7 +3,7 @@
namespace BusinessLogic\Navigation; namespace BusinessLogic\Navigation;
class CustomNavElementPlace { class CustomNavElementPlace extends \BaseClass {
const HOMEPAGE_BLOCK = 1; const HOMEPAGE_BLOCK = 1;
const CUSTOMER_NAVIGATION = 2; const CUSTOMER_NAVIGATION = 2;
const ADMIN_NAVIGATION = 3; const ADMIN_NAVIGATION = 3;

@ -3,7 +3,7 @@
namespace BusinessLogic\Navigation; namespace BusinessLogic\Navigation;
class Direction { class Direction extends \BaseClass {
const UP = 'up'; const UP = 'up';
const DOWN = 'down'; const DOWN = 'down';
} }

@ -5,7 +5,7 @@ namespace BusinessLogic\Security;
use DataAccess\Security\BanGateway; use DataAccess\Security\BanGateway;
class BanRetriever { class BanRetriever extends \BaseClass {
/** /**
* @var BanGateway * @var BanGateway
*/ */

@ -3,7 +3,7 @@
namespace BusinessLogic\Security; namespace BusinessLogic\Security;
class BannedEmail { class BannedEmail extends \BaseClass {
/** /**
* @var int * @var int
*/ */

@ -3,7 +3,7 @@
namespace BusinessLogic\Security; namespace BusinessLogic\Security;
class BannedIp { class BannedIp extends \BaseClass {
/** /**
* @var int * @var int
*/ */

@ -3,7 +3,7 @@
namespace BusinessLogic\Security; namespace BusinessLogic\Security;
class PermissionChecker { class PermissionChecker extends \BaseClass {
/** /**
* @param $userContext UserContext * @param $userContext UserContext
* @param $permission string * @param $permission string

@ -3,7 +3,7 @@
namespace BusinessLogic\Security; namespace BusinessLogic\Security;
class UserContext { class UserContext extends \BaseClass {
/* @var $id int */ /* @var $id int */
public $id; public $id;

@ -8,7 +8,7 @@ use BusinessLogic\Exceptions\MissingAuthenticationTokenException;
use BusinessLogic\Helpers; use BusinessLogic\Helpers;
use DataAccess\Security\UserGateway; use DataAccess\Security\UserGateway;
class UserContextBuilder { class UserContextBuilder extends \BaseClass {
/** /**
* @var UserGateway * @var UserGateway
*/ */

@ -3,7 +3,7 @@
namespace BusinessLogic\Security; namespace BusinessLogic\Security;
class UserContextNotifications { class UserContextNotifications extends \BaseClass {
public $newUnassigned; public $newUnassigned;
public $newAssignedToMe; public $newAssignedToMe;
public $replyUnassigned; public $replyUnassigned;

@ -3,7 +3,7 @@
namespace BusinessLogic\Security; namespace BusinessLogic\Security;
class UserContextPreferences { class UserContextPreferences extends \BaseClass {
public $afterReply; public $afterReply;
public $autoStartTimeWorked; public $autoStartTimeWorked;
public $autoreload; public $autoreload;

@ -9,7 +9,7 @@
namespace BusinessLogic\Security; namespace BusinessLogic\Security;
class UserPrivilege { class UserPrivilege extends \BaseClass {
const CAN_VIEW_TICKETS = 'can_view_tickets'; const CAN_VIEW_TICKETS = 'can_view_tickets';
const CAN_REPLY_TO_TICKETS = 'can_reply_tickets'; const CAN_REPLY_TO_TICKETS = 'can_reply_tickets';
const CAN_EDIT_TICKETS = 'can_edit_tickets'; const CAN_EDIT_TICKETS = 'can_edit_tickets';

@ -6,7 +6,7 @@ namespace BusinessLogic\Security;
use BusinessLogic\Tickets\Ticket; use BusinessLogic\Tickets\Ticket;
use DataAccess\Security\UserGateway; use DataAccess\Security\UserGateway;
class UserToTicketChecker { class UserToTicketChecker extends \BaseClass {
/* @var $userGateway UserGateway */ /* @var $userGateway UserGateway */
private $userGateway; private $userGateway;

@ -5,7 +5,7 @@ namespace BusinessLogic\Settings;
use DataAccess\Settings\ModsForHeskSettingsGateway; use DataAccess\Settings\ModsForHeskSettingsGateway;
class ApiChecker { class ApiChecker extends \BaseClass {
/* @var $modsForHeskSettingsGateway ModsForHeskSettingsGateway */ /* @var $modsForHeskSettingsGateway ModsForHeskSettingsGateway */
private $modsForHeskSettingsGateway; private $modsForHeskSettingsGateway;

@ -5,7 +5,7 @@ namespace BusinessLogic\Settings;
// TODO Test! // TODO Test!
use DataAccess\Settings\ModsForHeskSettingsGateway; use DataAccess\Settings\ModsForHeskSettingsGateway;
class SettingsRetriever { class SettingsRetriever extends \BaseClass {
/* @var $modsForHeskSettingsGateway ModsForHeskSettingsGateway */ /* @var $modsForHeskSettingsGateway ModsForHeskSettingsGateway */
private $modsForHeskSettingsGateway; private $modsForHeskSettingsGateway;

@ -3,7 +3,7 @@
namespace BusinessLogic\Statuses; namespace BusinessLogic\Statuses;
class Closable { class Closable extends \BaseClass {
const YES = "yes"; const YES = "yes";
const STAFF_ONLY = "sonly"; const STAFF_ONLY = "sonly";
const CUSTOMERS_ONLY = "conly"; const CUSTOMERS_ONLY = "conly";

@ -3,7 +3,7 @@
namespace BusinessLogic\Statuses; namespace BusinessLogic\Statuses;
class DefaultStatusForAction { class DefaultStatusForAction extends \BaseClass {
const NEW_TICKET = "IsNewTicketStatus"; const NEW_TICKET = "IsNewTicketStatus";
const CLOSED_STATUS = "IsClosed"; const CLOSED_STATUS = "IsClosed";
const CLOSED_BY_CLIENT = "IsClosedByClient"; const CLOSED_BY_CLIENT = "IsClosedByClient";

@ -3,7 +3,7 @@
namespace BusinessLogic\Statuses; namespace BusinessLogic\Statuses;
class Status { class Status extends \BaseClass {
static function fromDatabase($row, $languageRs) { static function fromDatabase($row, $languageRs) {
$status = new Status(); $status = new Status();
$status->id = intval($row['ID']); $status->id = intval($row['ID']);

@ -6,7 +6,7 @@ namespace BusinessLogic\Statuses;
use DataAccess\Statuses\StatusGateway; use DataAccess\Statuses\StatusGateway;
// TODO Test! // TODO Test!
class StatusRetriever { class StatusRetriever extends \BaseClass {
/* @var $statusGateway StatusGateway */ /* @var $statusGateway StatusGateway */
private $statusGateway; private $statusGateway;

@ -3,7 +3,7 @@
namespace BusinessLogic\Tickets; namespace BusinessLogic\Tickets;
class Attachment { class Attachment extends \BaseClass {
/** /**
* @var int * @var int
*/ */

@ -8,7 +8,7 @@ use BusinessLogic\Security\UserPrivilege;
use DataAccess\Categories\CategoryGateway; use DataAccess\Categories\CategoryGateway;
use DataAccess\Security\UserGateway; use DataAccess\Security\UserGateway;
class Autoassigner { class Autoassigner extends \BaseClass {
/* @var $categoryGateway CategoryGateway */ /* @var $categoryGateway CategoryGateway */
private $categoryGateway; private $categoryGateway;

@ -2,7 +2,7 @@
namespace BusinessLogic\Tickets; namespace BusinessLogic\Tickets;
class CreateTicketByCustomerModel { class CreateTicketByCustomerModel extends \BaseClass {
/** /**
* @var string * @var string
*/ */

@ -3,7 +3,7 @@
namespace BusinessLogic\Tickets; namespace BusinessLogic\Tickets;
class CreatedTicketModel { class CreatedTicketModel extends \BaseClass {
/* @var $ticket Ticket */ /* @var $ticket Ticket */
public $ticket; public $ticket;

@ -3,7 +3,7 @@
namespace BusinessLogic\Tickets\CustomFields; namespace BusinessLogic\Tickets\CustomFields;
class CustomFieldValidator { class CustomFieldValidator extends \BaseClass {
static function isCustomFieldInCategory($customFieldId, $categoryId, $staff, $heskSettings) { static function isCustomFieldInCategory($customFieldId, $categoryId, $staff, $heskSettings) {
$customField = $heskSettings['custom_fields']["custom{$customFieldId}"]; $customField = $heskSettings['custom_fields']["custom{$customFieldId}"];

@ -3,7 +3,7 @@
namespace BusinessLogic\Tickets; namespace BusinessLogic\Tickets;
class EditTicketModel { class EditTicketModel extends \BaseClass {
/* @var $id int */ /* @var $id int */
public $id; public $id;

@ -3,9 +3,7 @@
namespace BusinessLogic\Tickets\Exceptions; namespace BusinessLogic\Tickets\Exceptions;
use Exception; class UnableToGenerateTrackingIdException extends \BaseException {
class UnableToGenerateTrackingIdException extends Exception {
public function __construct() { public function __construct() {
parent::__construct("Error generating a unique ticket ID."); parent::__construct("Error generating a unique ticket ID.");
} }

@ -10,7 +10,7 @@ use BusinessLogic\ValidationModel;
use BusinessLogic\Validators; use BusinessLogic\Validators;
use Core\Constants\CustomField; use Core\Constants\CustomField;
class NewTicketValidator { class NewTicketValidator extends \BaseClass {
/** /**
* @var $categoryRetriever CategoryRetriever * @var $categoryRetriever CategoryRetriever
*/ */

@ -9,7 +9,7 @@
namespace BusinessLogic\Tickets; namespace BusinessLogic\Tickets;
class Reply { class Reply extends \BaseClass {
/** /**
* @var $id int * @var $id int
*/ */

@ -3,7 +3,7 @@
namespace BusinessLogic\Tickets; namespace BusinessLogic\Tickets;
class Ticket { class Ticket extends \BaseClass {
static function fromDatabaseRow($row, $linkedTicketsRs, $repliesRs, $heskSettings) { static function fromDatabaseRow($row, $linkedTicketsRs, $repliesRs, $heskSettings) {
$ticket = new Ticket(); $ticket = new Ticket();
$ticket->id = intval($row['id']); $ticket->id = intval($row['id']);

@ -12,7 +12,7 @@ use DataAccess\Settings\ModsForHeskSettingsGateway;
use DataAccess\Statuses\StatusGateway; use DataAccess\Statuses\StatusGateway;
use DataAccess\Tickets\TicketGateway; use DataAccess\Tickets\TicketGateway;
class TicketCreator { class TicketCreator extends \BaseClass {
/** /**
* @var $newTicketValidator NewTicketValidator * @var $newTicketValidator NewTicketValidator
*/ */

@ -10,7 +10,7 @@ use BusinessLogic\Security\UserPrivilege;
use BusinessLogic\Security\UserToTicketChecker; use BusinessLogic\Security\UserToTicketChecker;
use DataAccess\Tickets\TicketGateway; use DataAccess\Tickets\TicketGateway;
class TicketDeleter { class TicketDeleter extends \BaseClass {
/* @var $ticketGateway TicketGateway */ /* @var $ticketGateway TicketGateway */
private $ticketGateway; private $ticketGateway;

@ -15,7 +15,7 @@ use BusinessLogic\Validators;
use Core\Constants\CustomField; use Core\Constants\CustomField;
use DataAccess\Tickets\TicketGateway; use DataAccess\Tickets\TicketGateway;
class TicketEditor { class TicketEditor extends \BaseClass {
/* @var $ticketGateway TicketGateway */ /* @var $ticketGateway TicketGateway */
private $ticketGateway; private $ticketGateway;

@ -3,7 +3,7 @@
namespace BusinessLogic\Tickets; namespace BusinessLogic\Tickets;
class TicketGatewayGeneratedFields { class TicketGatewayGeneratedFields extends \BaseClass {
public $id; public $id;
public $dateCreated; public $dateCreated;
public $dateModified; public $dateModified;

@ -10,7 +10,7 @@ use BusinessLogic\Security\UserToTicketChecker;
use BusinessLogic\ValidationModel; use BusinessLogic\ValidationModel;
use DataAccess\Tickets\TicketGateway; use DataAccess\Tickets\TicketGateway;
class TicketRetriever { class TicketRetriever extends \BaseClass {
/** /**
* @var $ticketGateway TicketGateway * @var $ticketGateway TicketGateway
*/ */

@ -4,7 +4,7 @@ namespace BusinessLogic\Tickets;
use DataAccess\Tickets\TicketGateway; use DataAccess\Tickets\TicketGateway;
class TicketValidators { class TicketValidators extends \BaseClass {
/** /**
* @var $ticketGateway TicketGateway * @var $ticketGateway TicketGateway
*/ */

@ -6,7 +6,7 @@ namespace BusinessLogic\Tickets;
use BusinessLogic\Tickets\Exceptions\UnableToGenerateTrackingIdException; use BusinessLogic\Tickets\Exceptions\UnableToGenerateTrackingIdException;
use DataAccess\Tickets\TicketGateway; use DataAccess\Tickets\TicketGateway;
class TrackingIdGenerator { class TrackingIdGenerator extends \BaseClass {
/** /**
* @var $ticketGateway TicketGateway * @var $ticketGateway TicketGateway
*/ */

@ -11,7 +11,7 @@ namespace BusinessLogic\Tickets;
use DataAccess\Tickets\VerifiedEmailGateway; use DataAccess\Tickets\VerifiedEmailGateway;
class VerifiedEmailChecker { class VerifiedEmailChecker extends \BaseClass {
/** /**
* @var $verifiedEmailGateway VerifiedEmailGateway * @var $verifiedEmailGateway VerifiedEmailGateway
*/ */

@ -2,7 +2,7 @@
namespace BusinessLogic; namespace BusinessLogic;
class ValidationModel { class ValidationModel extends \BaseClass {
/** /**
* @var array * @var array
*/ */

@ -3,7 +3,7 @@
namespace BusinessLogic; namespace BusinessLogic;
class Validators { class Validators extends \BaseClass {
/** /**
* @param string $address - the email address * @param string $address - the email address
* @param array $multiple_emails - true if HESK (or custom field) supports multiple emails * @param array $multiple_emails - true if HESK (or custom field) supports multiple emails

@ -7,7 +7,7 @@ use BusinessLogic\Attachments\Attachment;
use BusinessLogic\Attachments\AttachmentRetriever; use BusinessLogic\Attachments\AttachmentRetriever;
use BusinessLogic\Exceptions\ApiFriendlyException; use BusinessLogic\Exceptions\ApiFriendlyException;
class PublicAttachmentController { class PublicAttachmentController extends \BaseClass {
static function getRaw($trackingId, $attachmentId) { static function getRaw($trackingId, $attachmentId) {
global $hesk_settings, $applicationContext, $userContext; global $hesk_settings, $applicationContext, $userContext;

@ -11,7 +11,7 @@ use BusinessLogic\Helpers;
use BusinessLogic\Security\UserToTicketChecker; use BusinessLogic\Security\UserToTicketChecker;
use Controllers\JsonRetriever; use Controllers\JsonRetriever;
class StaffTicketAttachmentsController { class StaffTicketAttachmentsController extends \BaseClass {
function get($ticketId, $attachmentId) { function get($ticketId, $attachmentId) {
global $hesk_settings, $applicationContext, $userContext; global $hesk_settings, $applicationContext, $userContext;

@ -9,7 +9,7 @@ use BusinessLogic\Exceptions\ApiFriendlyException;
use BusinessLogic\Helpers; use BusinessLogic\Helpers;
use Controllers\JsonRetriever; use Controllers\JsonRetriever;
class CategoryController { class CategoryController extends \BaseClass {
function get($id) { function get($id) {
$categories = self::getAllCategories(); $categories = self::getAllCategories();

@ -6,7 +6,7 @@ namespace Controllers;
use BusinessLogic\Exceptions\InternalUseOnlyException; use BusinessLogic\Exceptions\InternalUseOnlyException;
use BusinessLogic\Helpers; use BusinessLogic\Helpers;
abstract class InternalApiController { abstract class InternalApiController extends \BaseClass {
static function staticCheckForInternalUseOnly() { static function staticCheckForInternalUseOnly() {
$tokenHeader = Helpers::getHeader('X-AUTH-TOKEN'); $tokenHeader = Helpers::getHeader('X-AUTH-TOKEN');
if ($tokenHeader !== null && trim($tokenHeader) !== '') { if ($tokenHeader !== null && trim($tokenHeader) !== '') {

@ -3,7 +3,7 @@
namespace Controllers; namespace Controllers;
class JsonRetriever { class JsonRetriever extends \BaseClass {
/** /**
* Support POST, PUT, and PATCH request (and possibly more) * Support POST, PUT, and PATCH request (and possibly more)
* *

@ -5,7 +5,7 @@ namespace Controllers\Settings;
use BusinessLogic\Settings\SettingsRetriever; use BusinessLogic\Settings\SettingsRetriever;
class SettingsController { class SettingsController extends \BaseClass {
function get() { function get() {
global $applicationContext, $hesk_settings; global $applicationContext, $hesk_settings;

@ -5,7 +5,7 @@ namespace Controllers\Statuses;
use BusinessLogic\Statuses\StatusRetriever; use BusinessLogic\Statuses\StatusRetriever;
class StatusController { class StatusController extends \BaseClass {
function get() { function get() {
global $applicationContext, $hesk_settings; global $applicationContext, $hesk_settings;

@ -3,7 +3,7 @@
namespace Controllers\System; namespace Controllers\System;
class HeskVersionController { class HeskVersionController extends \BaseClass {
static function getHeskVersion() { static function getHeskVersion() {
global $hesk_settings; global $hesk_settings;

@ -10,7 +10,7 @@ use BusinessLogic\ValidationModel;
use Controllers\JsonRetriever; use Controllers\JsonRetriever;
class CustomerTicketController { class CustomerTicketController extends \BaseClass {
function get() { function get() {
global $applicationContext, $hesk_settings; global $applicationContext, $hesk_settings;

@ -10,7 +10,7 @@ use BusinessLogic\Tickets\TicketEditor;
use BusinessLogic\Tickets\TicketRetriever; use BusinessLogic\Tickets\TicketRetriever;
use Controllers\JsonRetriever; use Controllers\JsonRetriever;
class StaffTicketController { class StaffTicketController extends \BaseClass {
function get($id) { function get($id) {
global $applicationContext, $userContext, $hesk_settings; global $applicationContext, $userContext, $hesk_settings;

@ -3,7 +3,7 @@
namespace Core\Constants; namespace Core\Constants;
class CustomField { class CustomField extends \BaseClass {
const RADIO = 'radio'; const RADIO = 'radio';
const SELECT = 'select'; const SELECT = 'select';
const CHECKBOX = 'checkbox'; const CHECKBOX = 'checkbox';

@ -3,7 +3,7 @@
namespace Core\Constants; namespace Core\Constants;
class Priority { class Priority extends \BaseClass {
const CRITICAL = 0; const CRITICAL = 0;
const HIGH = 1; const HIGH = 1;
const MEDIUM = 2; const MEDIUM = 2;

@ -2,9 +2,7 @@
namespace Core\Exceptions; namespace Core\Exceptions;
use Exception; class SQLException extends \BaseException {
class SQLException extends Exception {
/** /**
* @var $failingQuery string * @var $failingQuery string
*/ */

@ -5,7 +5,7 @@ namespace DataAccess;
use Exception; use Exception;
class CommonDao { class CommonDao extends \BaseClass {
/** /**
* @throws Exception if the database isn't properly configured * @throws Exception if the database isn't properly configured
*/ */

@ -3,9 +3,7 @@
namespace DataAccess\Files; namespace DataAccess\Files;
use BusinessLogic\Exceptions\ApiFriendlyException; class FileDeleter extends \BaseClass {
class FileDeleter {
function deleteFile($name, $folder) { function deleteFile($name, $folder) {
$path = __DIR__ . "/../../../{$folder}/{$name}"; $path = __DIR__ . "/../../../{$folder}/{$name}";
if (!file_exists($path)) { if (!file_exists($path)) {

@ -5,7 +5,7 @@ namespace DataAccess\Files;
use BusinessLogic\Exceptions\ApiFriendlyException; use BusinessLogic\Exceptions\ApiFriendlyException;
class FileReader { class FileReader extends \BaseClass {
/** /**
* @param $name string - The file name (including extension) * @param $name string - The file name (including extension)
* @param $folder - The folder name (relative to the ROOT of the helpdesk) * @param $folder - The folder name (relative to the ROOT of the helpdesk)

@ -3,7 +3,7 @@
namespace DataAccess\Files; namespace DataAccess\Files;
class FileWriter { class FileWriter extends \BaseClass {
/** /**
* @param $name string - The file name (including extension) * @param $name string - The file name (including extension)
* @param $folder - The folder name (relative to the ROOT of the helpdesk) * @param $folder - The folder name (relative to the ROOT of the helpdesk)

@ -3,7 +3,7 @@
namespace DataAccess\Logging; namespace DataAccess\Logging;
class Severity { class Severity extends \BaseClass {
const DEBUG = 0; const DEBUG = 0;
const INFO = 1; const INFO = 1;
const WARNING = 2; const WARNING = 2;

@ -42,7 +42,7 @@ class Link
self::$routes = $routes; self::$routes = $routes;
$method = self::getRequestMethod(); $method = self::getRequestMethod();
$acceptedMethods = RequestMethod::ALL; $acceptedMethods = RequestMethod::all();
$path = '/'; $path = '/';
$handler = null; $handler = null;
$matched = array(); $matched = array();

@ -50,7 +50,7 @@ function assertApiIsEnabled() {
global $applicationContext, $hesk_settings; global $applicationContext, $hesk_settings;
/* @var $apiChecker \BusinessLogic\Settings\ApiChecker */ /* @var $apiChecker \BusinessLogic\Settings\ApiChecker */
$apiChecker = $applicationContext->get(\BusinessLogic\Settings\ApiChecker::class); $apiChecker = $applicationContext->get(\BusinessLogic\Settings\ApiChecker::clazz());
if (!$apiChecker->isApiEnabled($hesk_settings)) { if (!$apiChecker->isApiEnabled($hesk_settings)) {
print output(array('message' => 'API Disabled'), 404); print output(array('message' => 'API Disabled'), 404);
@ -77,7 +77,7 @@ function buildUserContext($xAuthToken) {
global $applicationContext, $userContext, $hesk_settings; global $applicationContext, $userContext, $hesk_settings;
/* @var $userContextBuilder \BusinessLogic\Security\UserContextBuilder */ /* @var $userContextBuilder \BusinessLogic\Security\UserContextBuilder */
$userContextBuilder = $applicationContext->get(\BusinessLogic\Security\UserContextBuilder::class); $userContextBuilder = $applicationContext->get(\BusinessLogic\Security\UserContextBuilder::clazz());
$userContext = $userContextBuilder->buildUserContext($xAuthToken, $hesk_settings); $userContext = $userContextBuilder->buildUserContext($xAuthToken, $hesk_settings);
} }
@ -98,12 +98,12 @@ function exceptionHandler($exception) {
} }
// We don't cast API Friendly Exceptions as they're user-generated errors // We don't cast API Friendly Exceptions as they're user-generated errors
if (exceptionIsOfType($exception, \BusinessLogic\Exceptions\ApiFriendlyException::class)) { if (exceptionIsOfType($exception, \BusinessLogic\Exceptions\ApiFriendlyException::clazz())) {
/* @var $castedException \BusinessLogic\Exceptions\ApiFriendlyException */ /* @var $castedException \BusinessLogic\Exceptions\ApiFriendlyException */
$castedException = $exception; $castedException = $exception;
print_error($castedException->title, $castedException->getMessage(), $castedException->httpResponseCode); print_error($castedException->title, $castedException->getMessage(), $castedException->httpResponseCode);
} elseif (exceptionIsOfType($exception, \Core\Exceptions\SQLException::class)) { } elseif (exceptionIsOfType($exception, \Core\Exceptions\SQLException::clazz())) {
/* @var $castedException \Core\Exceptions\SQLException */ /* @var $castedException \Core\Exceptions\SQLException */
$castedException = $exception; $castedException = $exception;
@ -138,7 +138,7 @@ function tryToLog($location, $message, $stackTrace, $userContext, $heskSettings)
global $applicationContext; global $applicationContext;
/* @var $loggingGateway \DataAccess\Logging\LoggingGateway */ /* @var $loggingGateway \DataAccess\Logging\LoggingGateway */
$loggingGateway = $applicationContext->get(\DataAccess\Logging\LoggingGateway::class); $loggingGateway = $applicationContext->get(\DataAccess\Logging\LoggingGateway::clazz());
try { try {
return $loggingGateway->logError($location, $message, $stackTrace, $userContext, $heskSettings); return $loggingGateway->logError($location, $message, $stackTrace, $userContext, $heskSettings);
@ -183,41 +183,41 @@ Link::before('globalBefore');
Link::all(array( Link::all(array(
// Categories // Categories
'/v1/categories/all' => action(\Controllers\Categories\CategoryController::class . '::printAllCategories', [RequestMethod::GET], SecurityHandler::INTERNAL_OR_AUTH_TOKEN), '/v1/categories/all' => action(\Controllers\Categories\CategoryController::clazz() . '::printAllCategories', [RequestMethod::GET], SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
'/v1/categories' => action(\Controllers\Categories\CategoryController::class, [RequestMethod::POST], SecurityHandler::INTERNAL_OR_AUTH_TOKEN), '/v1/categories' => action(\Controllers\Categories\CategoryController::clazz(), [RequestMethod::POST], SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
'/v1/categories/{i}' => action(\Controllers\Categories\CategoryController::class, [RequestMethod::GET, RequestMethod::PUT, RequestMethod::DELETE], SecurityHandler::INTERNAL_OR_AUTH_TOKEN), '/v1/categories/{i}' => action(\Controllers\Categories\CategoryController::clazz(), [RequestMethod::GET, RequestMethod::PUT, RequestMethod::DELETE], SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
'/v1-internal/categories/{i}/sort/{s}' => action(\Controllers\Categories\CategoryController::class . '::sort', [RequestMethod::POST], SecurityHandler::INTERNAL), '/v1-internal/categories/{i}/sort/{s}' => action(\Controllers\Categories\CategoryController::clazz() . '::sort', [RequestMethod::POST], SecurityHandler::INTERNAL),
// Tickets // Tickets
'/v1/tickets' => action(\Controllers\Tickets\CustomerTicketController::class, RequestMethod::all()), '/v1/tickets' => action(\Controllers\Tickets\CustomerTicketController::clazz(), RequestMethod::all()),
// Tickets - Staff // Tickets - Staff
'/v1/staff/tickets/{i}' => action(\Controllers\Tickets\StaffTicketController::class, RequestMethod::all()), '/v1/staff/tickets/{i}' => action(\Controllers\Tickets\StaffTicketController::clazz(), RequestMethod::all()),
// Attachments // Attachments
'/v1/tickets/{a}/attachments/{i}' => action(\Controllers\Attachments\PublicAttachmentController::class . '::getRaw', RequestMethod::all()), '/v1/tickets/{a}/attachments/{i}' => action(\Controllers\Attachments\PublicAttachmentController::clazz() . '::getRaw', RequestMethod::all()),
'/v1/staff/tickets/{i}/attachments' => action(\Controllers\Attachments\StaffTicketAttachmentsController::class, RequestMethod::all()), '/v1/staff/tickets/{i}/attachments' => action(\Controllers\Attachments\StaffTicketAttachmentsController::clazz(), RequestMethod::all()),
'/v1/staff/tickets/{i}/attachments/{i}' => action(\Controllers\Attachments\StaffTicketAttachmentsController::class, RequestMethod::all()), '/v1/staff/tickets/{i}/attachments/{i}' => action(\Controllers\Attachments\StaffTicketAttachmentsController::clazz(), RequestMethod::all()),
// Statuses // Statuses
'/v1/statuses' => action(\Controllers\Statuses\StatusController::class, RequestMethod::all()), '/v1/statuses' => action(\Controllers\Statuses\StatusController::clazz(), RequestMethod::all()),
// Settings // Settings
'/v1/settings' => action(\Controllers\Settings\SettingsController::class, RequestMethod::all()), '/v1/settings' => action(\Controllers\Settings\SettingsController::clazz(), RequestMethod::all()),
/* Internal use only routes */ /* Internal use only routes */
// Resend email response // Resend email response
'/v1-internal/staff/tickets/{i}/resend-email' => '/v1-internal/staff/tickets/{i}/resend-email' =>
action(\Controllers\Tickets\ResendTicketEmailToCustomerController::class, RequestMethod::all(), SecurityHandler::INTERNAL), action(\Controllers\Tickets\ResendTicketEmailToCustomerController::clazz(), RequestMethod::all(), SecurityHandler::INTERNAL),
// Custom Navigation // Custom Navigation
'/v1-internal/custom-navigation/all' => '/v1-internal/custom-navigation/all' =>
action(\Controllers\Navigation\CustomNavElementController::class . '::getAll', RequestMethod::all(), SecurityHandler::INTERNAL), action(\Controllers\Navigation\CustomNavElementController::clazz() . '::getAll', RequestMethod::all(), SecurityHandler::INTERNAL),
'/v1-internal/custom-navigation' => '/v1-internal/custom-navigation' =>
action(\Controllers\Navigation\CustomNavElementController::class, RequestMethod::all(), SecurityHandler::INTERNAL), action(\Controllers\Navigation\CustomNavElementController::clazz(), RequestMethod::all(), SecurityHandler::INTERNAL),
'/v1-internal/custom-navigation/{i}' => '/v1-internal/custom-navigation/{i}' =>
action(\Controllers\Navigation\CustomNavElementController::class, RequestMethod::all(), SecurityHandler::INTERNAL), action(\Controllers\Navigation\CustomNavElementController::clazz(), RequestMethod::all(), SecurityHandler::INTERNAL),
'/v1-internal/custom-navigation/{i}/sort/{s}' => '/v1-internal/custom-navigation/{i}/sort/{s}' =>
action(\Controllers\Navigation\CustomNavElementController::class . '::sort', RequestMethod::all(), SecurityHandler::INTERNAL), action(\Controllers\Navigation\CustomNavElementController::clazz() . '::sort', RequestMethod::all(), SecurityHandler::INTERNAL),
'/v1-public/hesk-version' => '/v1-public/hesk-version' =>
action(\Controllers\System\HeskVersionController::class . '::getHeskVersion', RequestMethod::all(), SecurityHandler::OPEN), action(\Controllers\System\HeskVersionController::clazz() . '::getHeskVersion', RequestMethod::all(), SecurityHandler::OPEN),
'/v1-public/mods-for-hesk-version' => '/v1-public/mods-for-hesk-version' =>
action(\Controllers\System\HeskVersionController::class . '::getModsForHeskVersion', RequestMethod::all(), SecurityHandler::OPEN), action(\Controllers\System\HeskVersionController::clazz() . '::getModsForHeskVersion', RequestMethod::all(), SecurityHandler::OPEN),
// Any URL that doesn't match goes to the 404 handler // Any URL that doesn't match goes to the 404 handler
'404' => 'handle404' '404' => 'handle404'

Loading…
Cancel
Save