Update composer.json and ApplicationContext
This commit is contained in:
parent
64428872df
commit
ad2c96c667
@ -2,6 +2,11 @@
|
||||
|
||||
// Responsible for loading in all necessary classes. AKA a poor man's DI solution.
|
||||
use BusinessLogic\Categories\CategoryRetriever;
|
||||
use BusinessLogic\Emails\BasicEmailSender;
|
||||
use BusinessLogic\Emails\EmailSenderHelper;
|
||||
use BusinessLogic\Emails\EmailTemplateParser;
|
||||
use BusinessLogic\Emails\EmailTemplateRetriever;
|
||||
use BusinessLogic\Emails\MailgunEmailSender;
|
||||
use BusinessLogic\Security\BanRetriever;
|
||||
use BusinessLogic\Security\UserContextBuilder;
|
||||
use BusinessLogic\Tickets\Autoassigner;
|
||||
@ -10,11 +15,13 @@ use BusinessLogic\Tickets\TicketCreator;
|
||||
use BusinessLogic\Tickets\NewTicketValidator;
|
||||
use BusinessLogic\Tickets\TicketValidators;
|
||||
use BusinessLogic\Tickets\TrackingIdGenerator;
|
||||
use BusinessLogic\Tickets\VerifiedEmailChecker;
|
||||
use DataAccess\Categories\CategoryGateway;
|
||||
use DataAccess\Security\BanGateway;
|
||||
use DataAccess\Security\UserGateway;
|
||||
use DataAccess\Statuses\StatusGateway;
|
||||
use DataAccess\Tickets\TicketGateway;
|
||||
use DataAccess\Tickets\VerifiedEmailGateway;
|
||||
|
||||
|
||||
class ApplicationContext {
|
||||
@ -23,7 +30,11 @@ class ApplicationContext {
|
||||
function __construct() {
|
||||
$this->get = array();
|
||||
|
||||
// User Context
|
||||
// Verified Email Checker
|
||||
$this->get[VerifiedEmailGateway::class] = new VerifiedEmailGateway();
|
||||
$this->get[VerifiedEmailChecker::class] = new VerifiedEmailChecker($this->get[VerifiedEmailGateway::class]);
|
||||
|
||||
// Users
|
||||
$this->get[UserGateway::class] = new UserGateway();
|
||||
$this->get[UserContextBuilder::class] = new UserContextBuilder($this->get[UserGateway::class]);
|
||||
|
||||
@ -35,8 +46,22 @@ class ApplicationContext {
|
||||
$this->get[BanGateway::class] = new BanGateway();
|
||||
$this->get[BanRetriever::class] = new BanRetriever($this->get[BanGateway::class]);
|
||||
|
||||
// Tickets
|
||||
// Statuses
|
||||
$this->get[StatusGateway::class] = new StatusGateway();
|
||||
|
||||
// Email Sender
|
||||
$this->get[EmailTemplateRetriever::class] = new EmailTemplateRetriever();
|
||||
$this->get[EmailTemplateParser::class] = new EmailTemplateParser($this->get[StatusGateway::class],
|
||||
$this->get[CategoryGateway::class],
|
||||
$this->get[UserGateway::class],
|
||||
$this->get[EmailTemplateRetriever::class]);
|
||||
$this->get[BasicEmailSender::class] = new BasicEmailSender();
|
||||
$this->get[MailgunEmailSender::class] = new MailgunEmailSender();
|
||||
$this->get[EmailSenderHelper::class] = new EmailSenderHelper($this->get[EmailTemplateParser::class],
|
||||
$this->get[BasicEmailSender::class],
|
||||
$this->get[MailgunEmailSender::class]);
|
||||
|
||||
// Tickets
|
||||
$this->get[TicketGateway::class] = new TicketGateway();
|
||||
$this->get[TicketRetriever::class] = new TicketRetriever($this->get[TicketGateway::class]);
|
||||
$this->get[TicketValidators::class] = new TicketValidators($this->get[TicketGateway::class]);
|
||||
@ -49,6 +74,9 @@ class ApplicationContext {
|
||||
$this->get[TrackingIdGenerator::class],
|
||||
$this->get[Autoassigner::class],
|
||||
$this->get[StatusGateway::class],
|
||||
$this->get[TicketGateway::class]);
|
||||
$this->get[TicketGateway::class],
|
||||
$this->get[VerifiedEmailChecker::class],
|
||||
$this->get[EmailSenderHelper::class],
|
||||
$this->get[UserGateway::class]);
|
||||
}
|
||||
}
|
@ -148,6 +148,8 @@ class TicketCreator {
|
||||
$addressees = new Addressees();
|
||||
$addressees->to = array($ownerEmail);
|
||||
$this->emailSenderHelper->sendEmailForTicket(EmailTemplateRetriever::TICKET_ASSIGNED_TO_YOU, $ticketRequest->language, $addressees, $ticket, $heskSettings, $modsForHeskSettings);
|
||||
} else {
|
||||
// TODO email all users who should be notified
|
||||
}
|
||||
|
||||
return $ticket;
|
||||
|
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace DataAccess\Entities;
|
||||
|
||||
|
||||
use Spot\Entity;
|
||||
|
||||
class BaseEntity extends Entity {
|
||||
public static function table($tableName) {
|
||||
global $hesk_settings;
|
||||
|
||||
return parent::table($hesk_settings['db_pfix'] . $tableName);
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace DataAccess\Entities;
|
||||
|
||||
|
||||
class User extends BaseEntity {
|
||||
protected static $table = 'users';
|
||||
|
||||
public static function fields() {
|
||||
//@formatter:off
|
||||
return [
|
||||
'id' => ['type' => 'integer', 'primary' => true, 'autoincrement' => true],
|
||||
'user' => ['type' => 'string', 'required' => true, 'default' => ''],
|
||||
'pass' => ['type' => 'string', 'required' => true],
|
||||
'isadmin' => ['type' => 'string', 'required' => true, 'default' => '0'],
|
||||
'name' => ['type' => 'string', 'required' => true, 'default' => ''],
|
||||
'email' => ['type' => 'string', 'required' => true, 'default' => ''],
|
||||
'signature' => ['type' => 'string', 'required' => true, 'default' => ''],
|
||||
'language' => ['type' => 'string', 'required' => false],
|
||||
'categories' => ['type' => 'string', 'required' => true, 'default' => ''],
|
||||
'afterreply' => ['type' => 'string', 'required' => true, 'default' => '0'],
|
||||
'autostart' => ['type' => 'string', 'required' => true, 'default' => '1'],
|
||||
'autoreload' => ['type' => 'smallint', 'required' => true, 'default' => 0],
|
||||
'notify_customer_new' => ['type' => 'string', 'required' => true, 'default' => '1'],
|
||||
'notify_customer_reply' => ['type' => 'string', 'required' => true, 'default' => '1'],
|
||||
'show_suggested' => ['type' => 'string', 'required' => true, 'default' => '1'],
|
||||
'notify_new_unassigned' => ['type' => 'string', 'required' => true, 'default' => '1'],
|
||||
'notify_new_my' => ['type' => 'string', 'required' => true, 'default' => '1'],
|
||||
'notify_reply_unassigned' => ['type' => 'string', 'required' => true, 'default' => '1'],
|
||||
'notify_reply_my' => ['type' => 'string', 'required' => true, 'default' => '1'],
|
||||
'notify_assigned' => ['type' => 'string', 'required' => true, 'default' => '1'],
|
||||
'notify_pm' => ['type' => 'string', 'required' => true, 'default' => '1'],
|
||||
'notify_note' => ['type' => 'string', 'required' => true, 'default' => '1'],
|
||||
'notify_note_unassigned' => ['type' => 'string', 'required' => false, 'default' => '0'],
|
||||
'default_calendar_view' => ['type' => 'integer', 'required' => true, 'default' => '0'],
|
||||
'notify_overdue_unassigned' => ['type' => 'string', 'required' => true, 'default' => '0'],
|
||||
'default_list' => ['type' => 'string', 'required' => true, 'default' => ''],
|
||||
'autoassign' => ['type' => 'string', 'required' => true, 'default' => '1'],
|
||||
'heskprivileges' => ['type' => 'string', 'required' => false],
|
||||
'ratingneg' => ['type' => 'integer', 'required' => true, 'default' => 0],
|
||||
'ratingpos' => ['type' => 'integer', 'required' => true, 'default' => 0],
|
||||
'rating' => ['type' => 'float', 'required' => true, 'default' => 0],
|
||||
'replies' => ['type' => 'integer', 'required' => true, 'default' => 0],
|
||||
'active' => ['type' => 'string', 'required' => true, 'default' => '1'],
|
||||
'permission_template' => ['type' => 'integer', 'required' => false]
|
||||
];
|
||||
//@formatter:on
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
// Core requirements
|
||||
define('IN_SCRIPT', 1);
|
||||
define('HESK_PATH', '../');
|
||||
require_once(__DIR__ . 'vendor/autoload.php');
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
require_once(__DIR__ . '/bootstrap.php');
|
||||
require_once(__DIR__ . '/../hesk_settings.inc.php');
|
||||
require_once(__DIR__ . '/../inc/common.inc.php');
|
||||
@ -19,11 +19,6 @@ global $hesk_settings;
|
||||
// HESK files that require database access
|
||||
require_once(__DIR__ . '/../inc/custom_fields.inc.php');
|
||||
|
||||
// Load Spot ORM
|
||||
$config = new \Spot\Config();
|
||||
$config->addConnection('mysql', "mysql://{$hesk_settings['db_user']}:{$hesk_settings['db_pass']}@{$hesk_settings['db_host']}/{$hesk_settings['db_name']}");
|
||||
$spot = new \Spot\Locator($config);
|
||||
|
||||
// Load the ApplicationContext
|
||||
$applicationContext = new \ApplicationContext();
|
||||
//$modsForHeskSettings = mfh_getSettings();
|
@ -16,7 +16,6 @@
|
||||
"php-http/guzzle6-adapter": "^1.1",
|
||||
"php-http/message": "^1.5",
|
||||
"php-http/curl-client": "^1.7",
|
||||
"guzzlehttp/psr7": "^1.3",
|
||||
"vlucas/spot2": "~2.0"
|
||||
"guzzlehttp/psr7": "^1.3"
|
||||
}
|
||||
}
|
||||
|
@ -34,13 +34,20 @@ function buildUserContext($xAuthToken) {
|
||||
}
|
||||
|
||||
function errorHandler($errorNumber, $errorMessage, $errorFile, $errorLine) {
|
||||
exceptionHandler(new Exception(sprintf("%s:%d\n\n%s", $errorFile, $errorLine, $errorMessage)));
|
||||
if ($errorNumber === E_WARNING) {
|
||||
//-- TODO log a warning
|
||||
} elseif ($errorNumber === E_NOTICE || $errorNumber === E_USER_NOTICE) {
|
||||
//-- TODO log an info
|
||||
} else {
|
||||
exceptionHandler(new Exception(sprintf("%s:%d\n\n%s", $errorFile, $errorLine, $errorMessage)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $exception Exception
|
||||
*/
|
||||
function exceptionHandler($exception) {
|
||||
//-- TODO Log an error
|
||||
if (exceptionIsOfType($exception, \BusinessLogic\Exceptions\ApiFriendlyException::class)) {
|
||||
/* @var $castedException \BusinessLogic\Exceptions\ApiFriendlyException */
|
||||
$castedException = $exception;
|
||||
|
Loading…
x
Reference in New Issue
Block a user