Merge pull request #384 from SamMousa/use-composer-autoloader
Use composer autoloader for source files (except tests)
This commit is contained in:
commit
1533331e1d
|
@ -11,5 +11,8 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^5.7"
|
||||
},
|
||||
"autoload":{
|
||||
"classmap": ["libs/", "models/", "controllers/", "data/"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,4 @@
|
|||
<?php
|
||||
include 'article/add-topic.php';
|
||||
include 'article/edit-topic.php';
|
||||
include 'article/delete-topic.php';
|
||||
include 'article/add.php';
|
||||
include 'article/edit.php';
|
||||
include 'article/delete.php';
|
||||
include 'article/get-all.php';
|
||||
|
||||
$articleControllers = new ControllerGroup();
|
||||
$articleControllers->setGroupPath('/article');
|
||||
|
||||
|
|
|
@ -1,17 +1,4 @@
|
|||
<?php
|
||||
require_once 'staff/get.php';
|
||||
require_once 'staff/assign-ticket.php';
|
||||
require_once 'staff/un-assign-ticket.php';
|
||||
require_once 'staff/get-tickets.php';
|
||||
require_once 'staff/get-new-tickets.php';
|
||||
require_once 'staff/get-all-tickets.php';
|
||||
require_once 'staff/search-tickets.php';
|
||||
require_once 'staff/add.php';
|
||||
require_once 'staff/get-all.php';
|
||||
require_once 'staff/delete.php';
|
||||
require_once 'staff/edit.php';
|
||||
require_once 'staff/last-events.php';
|
||||
|
||||
$systemControllerGroup = new ControllerGroup();
|
||||
$systemControllerGroup->setGroupPath('/staff');
|
||||
|
||||
|
|
|
@ -1,32 +1,4 @@
|
|||
<?php
|
||||
require_once 'system/check-requirements.php';
|
||||
require_once 'system/init-database.php';
|
||||
require_once 'system/init-settings.php';
|
||||
require_once 'system/init-admin.php';
|
||||
require_once 'system/installation-done.php';
|
||||
require_once 'system/get-settings.php';
|
||||
require_once 'system/edit-settings.php';
|
||||
require_once 'system/add-department.php';
|
||||
require_once 'system/edit-department.php';
|
||||
require_once 'system/delete-department.php';
|
||||
require_once 'system/get-logs.php';
|
||||
require_once 'system/get-mail-templates.php';
|
||||
require_once 'system/edit-mail-template.php';
|
||||
require_once 'system/recover-mail-template.php';
|
||||
require_once 'system/disable-registration.php';
|
||||
require_once 'system/enable-registration.php';
|
||||
require_once 'system/disable-user-system.php';
|
||||
require_once 'system/enable-user-system.php';
|
||||
require_once 'system/add-api-key.php';
|
||||
require_once 'system/delete-api-key.php';
|
||||
require_once 'system/get-api-keys.php';
|
||||
require_once 'system/get-stats.php';
|
||||
require_once 'system/delete-all-users.php';
|
||||
require_once 'system/csv-import.php';
|
||||
require_once 'system/backup-database.php';
|
||||
require_once 'system/download.php';
|
||||
require_once 'system/test-smtp.php';
|
||||
|
||||
$systemControllerGroup = new ControllerGroup();
|
||||
$systemControllerGroup->setGroupPath('/system');
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
//include '../../config.php';
|
||||
use RedBeanPHP\Facade as RedBean;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,19 +1,4 @@
|
|||
<?php
|
||||
include 'ticket/create.php';
|
||||
include 'ticket/comment.php';
|
||||
include 'ticket/get.php';
|
||||
include 'ticket/check.php';
|
||||
include 'ticket/add-custom-response.php';
|
||||
include 'ticket/delete-custom-response.php';
|
||||
include 'ticket/edit-custom-response.php';
|
||||
include 'ticket/get-custom-responses.php';
|
||||
include 'ticket/change-department.php';
|
||||
include 'ticket/close.php';
|
||||
include 'ticket/re-open.php';
|
||||
include 'ticket/change-priority.php';
|
||||
include 'ticket/seen.php';
|
||||
include 'ticket/delete.php';
|
||||
|
||||
$ticketControllers = new ControllerGroup();
|
||||
$ticketControllers->setGroupPath('/ticket');
|
||||
|
||||
|
|
|
@ -1,23 +1,4 @@
|
|||
<?php
|
||||
include 'user/login.php';
|
||||
include 'user/signup.php';
|
||||
include 'user/logout.php';
|
||||
include 'user/check-session.php';
|
||||
include 'user/recover-password.php';
|
||||
include 'user/send-recover-password.php';
|
||||
include 'user/edit-password.php';
|
||||
include 'user/edit-email.php';
|
||||
include 'user/get.php';
|
||||
include 'user/get-users.php';
|
||||
include 'user/get-user.php';
|
||||
include 'user/delete.php';
|
||||
include 'user/ban.php';
|
||||
include 'user/un-ban.php';
|
||||
include 'user/list-ban.php';
|
||||
include 'user/verify.php';
|
||||
include 'user/enable.php';
|
||||
include 'user/disable.php';
|
||||
|
||||
$userControllers = new ControllerGroup();
|
||||
$userControllers->setGroupPath('/user');
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?php
|
||||
require_once 'data/MailTexts.php';
|
||||
|
||||
class InitialMails {
|
||||
|
||||
public static function getBody($templateCode, $texts) {
|
||||
|
|
|
@ -15,49 +15,10 @@ if(defined('MYSQL_HOST') && defined('MYSQL_DATABASE') && defined('MYSQL_USER') &
|
|||
\Slim\Slim::registerAutoLoader();
|
||||
$app = new \Slim\Slim();
|
||||
|
||||
// LOAD LIBRARIES
|
||||
include_once 'libs/Controller.php';
|
||||
include_once 'libs/ControllerGroup.php';
|
||||
include_once 'libs/Hashing.php';
|
||||
include_once 'libs/MailSender.php';
|
||||
include_once 'libs/Date.php';
|
||||
include_once 'libs/DataStoreList.php';
|
||||
include_once 'libs/LinearCongruentialGenerator.php';
|
||||
include_once 'libs/FileManager.php';
|
||||
include_once 'libs/FileDownloader.php';
|
||||
include_once 'libs/FileUploader.php';
|
||||
|
||||
Controller::init();
|
||||
|
||||
// LOAD DATA
|
||||
spl_autoload_register(function ($class) {
|
||||
$classPath = "data/{$class}.php";
|
||||
|
||||
if(file_exists($classPath)) {
|
||||
include_once $classPath;
|
||||
}
|
||||
});
|
||||
|
||||
// LOAD MODELS
|
||||
spl_autoload_register(function ($class) {
|
||||
$classPath = "models/{$class}.php";
|
||||
|
||||
if(file_exists($classPath)) {
|
||||
include_once $classPath;
|
||||
}
|
||||
});
|
||||
|
||||
// LOAD CUSTOM VALIDATIONS
|
||||
include_once 'libs/validations/dataStoreId.php';
|
||||
include_once 'libs/validations/userEmail.php';
|
||||
include_once 'libs/validations/staffEmail.php';
|
||||
include_once 'libs/validations/captcha.php';
|
||||
include_once 'libs/validations/validLanguage.php';
|
||||
include_once 'libs/validations/validTicketNumber.php';
|
||||
|
||||
// LOAD CONTROLLERS
|
||||
foreach (glob('controllers/*.php') as $controller) {
|
||||
include_once $controller;
|
||||
}
|
||||
|
||||
Controller::init();
|
||||
$app->run();
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
<?php
|
||||
require_once 'libs/Validator.php';
|
||||
require_once 'models/Session.php';
|
||||
|
||||
use RedBeanPHP\Facade as RedBean;
|
||||
|
||||
abstract class Controller {
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?php
|
||||
require_once 'models/DataStore.php';
|
||||
|
||||
class DataStoreList implements IteratorAggregate {
|
||||
private $list = [];
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?php
|
||||
require_once 'libs/Controller.php';
|
||||
|
||||
use Respect\Validation\Validator as DataValidator;
|
||||
|
||||
class ValidationException extends Exception {}
|
||||
|
|
|
@ -10,8 +10,6 @@ include_once 'tests/__mocks__/HashingMock.php';
|
|||
include_once 'tests/__mocks__/SessionCookieMock.php';
|
||||
include_once 'data/ERRORS.php';
|
||||
|
||||
include_once 'controllers/user/login.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class LoginControllerTest extends TestCase {
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?php
|
||||
include_once 'libs/Hashing.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class HashingTest extends TestCase {
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
<?php
|
||||
include_once 'libs/Hashing.php';
|
||||
include_once 'libs/LinearCongruentialGenerator.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class LinearCongruentialGeneratorTest extends TestCase {
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
<?php
|
||||
include_once 'tests/__lib__/Mock.php';
|
||||
include_once 'tests/__mocks__/RespectMock.php';
|
||||
include_once 'tests/__mocks__/SettingMock.php';
|
||||
include_once 'tests/__mocks__/APIKeyMock.php';
|
||||
include_once 'tests/__mocks__/ControllerMock.php';
|
||||
include_once 'tests/__mocks__/ReCaptchaMock.php';
|
||||
|
||||
include_once 'libs/validations/captcha.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CaptchaValidationTest extends TestCase {
|
||||
|
|
|
@ -3,7 +3,6 @@ include_once 'tests/__lib__/Mock.php';
|
|||
include_once 'tests/__mocks__/BeanMock.php';
|
||||
include_once 'tests/__mocks__/SlimMock.php';
|
||||
include_once 'tests/__mocks__/RedBeanMock.php';
|
||||
include_once 'models/DataStore.php';
|
||||
|
||||
use RedBeanPHP\Facade as RedBean;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
|
|
@ -3,7 +3,6 @@ include_once 'tests/__lib__/Mock.php';
|
|||
include_once 'tests/__mocks__/BeanMock.php';
|
||||
include_once 'tests/__mocks__/SettingMock.php';
|
||||
include_once 'tests/__mocks__/RedBeanMock.php';
|
||||
include_once 'models/MailTemplate.php';
|
||||
|
||||
use RedBeanPHP\Facade as RedBean;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
include_once 'tests/__lib__/Mock.php';
|
||||
include_once 'tests/__mocks__/SlimMock.php';
|
||||
include_once 'models/Response.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
|
Loading…
Reference in New Issue