Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/127 service factory #329

Merged
merged 9 commits into from
Mar 10, 2018
Merged
8 changes: 4 additions & 4 deletions Alpha/Controller/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Alpha\Util\Extension\TCPDFFacade;
use Alpha\Util\Http\Request;
use Alpha\Util\Http\Response;
use Alpha\Util\Http\Session\SessionProviderFactory;
use Alpha\Util\Service\ServiceFactory;
use Alpha\Util\File\FileUtils;
use Alpha\Model\Article;
use Alpha\Model\ArticleComment;
Expand Down Expand Up @@ -558,7 +558,7 @@ public function before_displayPageFoot_callback()
{
$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

$html = '';
$params = $this->request->getParams();
Expand Down Expand Up @@ -635,7 +635,7 @@ private function renderComments()
{
$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

$html = '';

Expand Down Expand Up @@ -707,7 +707,7 @@ private function renderVotes()
{
$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

$URL = FrontController::generateSecureURL('act=Alpha\Controller\ActiveRecordController&ActiveRecordType=Alpha\Model\ArticleVote');
$html = '<form action="'.$URL.'" method="post" accept-charset="UTF-8">';
Expand Down
4 changes: 2 additions & 2 deletions Alpha/Controller/CacheController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Alpha\Util\File\FileUtils;
use Alpha\Util\Security\SecurityUtils;
use Alpha\Util\Http\Response;
use Alpha\Util\Http\Session\SessionProviderFactory;
use Alpha\Util\Service\ServiceFactory;
use Alpha\Exception\IllegalArguementException;
use Alpha\Exception\SecurityException;
use Alpha\Exception\AlphaException;
Expand Down Expand Up @@ -213,7 +213,7 @@ public function doPOST($request)

$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

self::$logger->info('Cache contents deleted successfully by user ['.$session->get('currentUser')->get('username').'].');
} catch (AlphaException $e) {
Expand Down
26 changes: 13 additions & 13 deletions Alpha/Controller/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Alpha\Util\Config\ConfigProvider;
use Alpha\Util\Security\SecurityUtils;
use Alpha\Util\Helper\Validator;
use Alpha\Util\Http\Session\SessionProviderFactory;
use Alpha\Util\Service\ServiceFactory;
use Alpha\Util\Http\Request;
use Alpha\Util\Http\Response;
use Alpha\Util\Logging\Logger;
Expand Down Expand Up @@ -273,7 +273,7 @@ public function __construct($visibility = 'Public')
}

$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

if ($session->get('unitOfWork') !== false && is_array($session->get('unitOfWork'))) {
$this->setUnitOfWork($session->get('unitOfWork'));
Expand Down Expand Up @@ -490,7 +490,7 @@ public function setUnitOfWork($jobs)
// clear out any previous unit of work from the session
$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');
$session->delete('unitOfWork');
$this->firstJob = null;
$this->previousJob = null;
Expand Down Expand Up @@ -577,7 +577,7 @@ public function setUnitStartTime($year, $month, $day, $hour, $minute, $second)

$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

$this->unitStartTime->setTimestampValue($year, $month, $day, $hour, $minute, $second);
$session->set('unitStartTime', $this->unitStartTime->getValue());
Expand Down Expand Up @@ -619,7 +619,7 @@ public function setUnitEndTime($year, $month, $day, $hour, $minute, $second)

$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

$this->unitEndTime->setTimestampValue($year, $month, $day, $hour, $minute, $second);
$session->set('unitEndTime', $this->unitEndTime->getValue());
Expand Down Expand Up @@ -709,7 +709,7 @@ public function markDirty($object)

$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

$session->set('dirtyObjects', $this->dirtyObjects);

Expand Down Expand Up @@ -754,7 +754,7 @@ public function markNew($object)

$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

$session->set('newObjects', $this->newObjects);

Expand Down Expand Up @@ -893,7 +893,7 @@ public function clearUnitOfWorkAttributes()
{
$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

$session->delete('unitOfWork');
$this->unitOfWork = null;
Expand Down Expand Up @@ -1008,7 +1008,7 @@ public function accessError()
$config = ConfigProvider::getInstance();

$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

if ($session->get('currentUser') !== false) {
self::$logger->warn('The user ['.$session->get('currentUser')->get('email').'] attempted to access the resource ['.$this->request->getURI().'] but was denied due to insufficient rights');
Expand Down Expand Up @@ -1044,7 +1044,7 @@ public function checkRights()
$config = ConfigProvider::getInstance();

$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

if (method_exists($this, 'before_checkRights_callback')) {
$this->{'before_checkRights_callback'}();
Expand Down Expand Up @@ -1256,7 +1256,7 @@ public function setStatusMessage($message)
{
$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

$this->statusMessage = $message;
$session->set('statusMessage', $message);
Expand All @@ -1275,7 +1275,7 @@ public function getStatusMessage()
{
$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

$session->delete('statusMessage');

Expand Down Expand Up @@ -1682,7 +1682,7 @@ public function after_displayPageHead_callback()
$config = ConfigProvider::getInstance();

$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

if ($session->get('currentUser') !== false) {
$passwordResetRequired = SecurityUtils::checkAdminPasswordIsDefault($session->get('currentUser')->get('password'));
Expand Down
8 changes: 4 additions & 4 deletions Alpha/Controller/InstallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Alpha\Util\Logging\Logger;
use Alpha\Util\Config\ConfigProvider;
use Alpha\Util\Http\Response;
use Alpha\Util\Http\Session\SessionProviderFactory;
use Alpha\Util\Service\ServiceFactory;
use Alpha\Model\ActiveRecord;
use Alpha\Model\Rights;
use Alpha\Model\Person;
Expand Down Expand Up @@ -105,7 +105,7 @@ public function doGET($request)
$config = ConfigProvider::getInstance();

$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

// if there is nobody logged in, we will send them off to the Login controller to do so before coming back here
if ($session->get('currentUser') === false) {
Expand All @@ -122,7 +122,7 @@ public function doGET($request)
}

$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

$body = View::displayPageHead($this);

Expand Down Expand Up @@ -462,7 +462,7 @@ public function checkRights()

$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

if ($this->getVisibility() == 'Public') {
self::$logger->debug('<<checkRights [true]');
Expand Down
6 changes: 3 additions & 3 deletions Alpha/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Alpha\Util\Config\ConfigProvider;
use Alpha\Util\Http\Request;
use Alpha\Util\Http\Response;
use Alpha\Util\Http\Session\SessionProviderFactory;
use Alpha\Util\Service\ServiceFactory;
use Alpha\Util\Helper\Validator;
use Alpha\View\View;
use Alpha\View\PersonView;
Expand Down Expand Up @@ -195,7 +195,7 @@ public function doPOST($request)
$admin->set('ID', '00000000001');

$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');
$session->set('currentUser', $admin);

$response = new Response(301);
Expand Down Expand Up @@ -308,7 +308,7 @@ protected function doLoginAndRedirect($password)
if (!$this->personObject->isTransient() && $this->personObject->get('state') == 'Active') {
if (password_verify($password, $this->personObject->get('password'))) {
$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');
$session->set('currentUser', $this->personObject);

self::$logger->debug('Logging in ['.$this->personObject->get('email').'] at ['.date('Y-m-d H:i:s').']');
Expand Down
6 changes: 3 additions & 3 deletions Alpha/Controller/LogoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Alpha\Util\Logging\Logger;
use Alpha\Util\Config\ConfigProvider;
use Alpha\Util\Http\Session\SessionProviderFactory;
use Alpha\Util\Service\ServiceFactory;
use Alpha\Util\Http\Response;
use Alpha\Model\Person;
use Alpha\View\View;
Expand Down Expand Up @@ -77,7 +77,7 @@ public function __construct()

$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');

if ($session->get('currentUser') !== false) {
$this->setRecord($session->get('currentUser'));
Expand Down Expand Up @@ -114,7 +114,7 @@ public function doGET($request)
}

$sessionProvider = $config->get('session.provider.name');
$session = SessionProviderFactory::getInstance($sessionProvider);
$session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');
$session->destroy();

$body = View::displayPageHead($this);
Expand Down
4 changes: 2 additions & 2 deletions Alpha/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Alpha\Util\Config\ConfigProvider;
use Alpha\Util\Http\Request;
use Alpha\Util\Http\Response;
use Alpha\Util\Search\SearchProviderFactory;
use Alpha\Util\Service\ServiceFactory;
use Alpha\View\View;
use Alpha\View\Widget\Button;
use Alpha\Controller\Front\FrontController;
Expand Down Expand Up @@ -152,7 +152,7 @@ public function doGET($request)

$KPI->logStep('log search query');

$provider = SearchProviderFactory::getInstance('Alpha\Util\Search\SearchProviderTags');
$provider = ServiceFactory::getInstance('Alpha\Util\Search\SearchProviderTags', 'Alpha\Util\Search\SearchProviderInterface');

// if a Record name is provided, only search tags on that class, otherwise search all records
if (isset($params['ActiveRecordType'])) {
Expand Down
Loading