Skip to content

Commit

Permalink
Version 2.23, released 04/01/2014.
Browse files Browse the repository at this point in the history
[Refactor] - Modified libraries concept to Service concepts. A Service is tightly related to a controller. It stores intelligence regarding what to do with validated information, which models request a CRUD, and informs the controller about the message to put into the related view.
[Refactor] - Modified Hecnel Framework in order to use the new Model architecture.
  • Loading branch information
HectorOrdonez committed Jan 4, 2014
1 parent 324e692 commit 1132965
Show file tree
Hide file tree
Showing 22 changed files with 317 additions and 380 deletions.
14 changes: 7 additions & 7 deletions application/controllers/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@
namespace application\controllers;

use application\engine\Controller;
use application\libraries\LoginLibrary;
use application\services\LoginService;
use engine\Encrypter;
use engine\Form;
use engine\Input;

class Login extends Controller
{
/**
* Defining $_library Library type.
* @var LoginLibrary $_library
* Defining $_service Service type.
* @var LoginService $_service
*/
protected $_library;
protected $_service;

/**
* Login constructor.
*/
public function __construct()
{
parent::__construct(new LoginLibrary);
parent::__construct(new LoginService);
}

/**
Expand Down Expand Up @@ -58,13 +58,13 @@ public function run()
);

// Logic
$login = $this->_library->login(
$login = $this->_service->login(
$form->getInput('name')->getValue(),
$form->getInput('password')->getValue()
);

// Resolution
if ($login === TRUE) {
if (true === $login) {
header('location: ' . _SYSTEM_BASE_URL . 'dashboard');
exit;
} else {
Expand Down
21 changes: 12 additions & 9 deletions application/controllers/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,30 @@
namespace application\controllers;

use application\engine\Controller;
use application\services\DashboardService;
use engine\Form;
use engine\Input;
use engine\Session;
use application\libraries\DashboardLibrary;


/**
* Class Dashboard
* @package application\controllers
*/
class Dashboard extends Controller
{
/**
* Defining $_library Library type.
* @var DashboardLibrary $_library
* Defining $_service Service type.
* @var DashboardService $_service
*/
protected $_library;
protected $_service;

/**
* Dashboard constructor.
* Verifies that the User has access to this class.
*/
public function __construct()
{
parent::__construct(new DashboardLibrary);
parent::__construct(new DashboardService);
$logged = Session::get('isUserLoggedIn');
if (FALSE === $logged) {
Session::destroy();
Expand Down Expand Up @@ -76,7 +79,7 @@ public function ajaxInsert()
->addRule('minLength', 50)
);

$json_response = $this->_library->ajaxInsert($form->getInput('data')->getValue());
$json_response = $this->_service->ajaxInsert($form->getInput('data')->getValue());

print json_encode($json_response);
}
Expand All @@ -88,7 +91,7 @@ public function ajaxInsert()
*/
public function getListings()
{
$json_response = $this->_library->getListings();
$json_response = $this->_service->getListings();

print json_encode($json_response);
}
Expand All @@ -105,6 +108,6 @@ public function deleteData()
->addRule('min', 1)
);

$this->_library->deleteData($form->getInput('id')->getValue());
$this->_service->deleteData($form->getInput('id')->getValue());
}
}
12 changes: 6 additions & 6 deletions application/controllers/help.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
namespace application\controllers;

use application\engine\Controller;
use application\libraries\HelpLibrary;
use application\services\HelpService;

class Help extends Controller
{
/**
* Defining $_library Library type.
* @var HelpLibrary $_library
* Defining $_service Service type.
* @var HelpService $_service
*/
protected $_library;
protected $_service;

/**
* Help constructor.
* Adds the Help style library. As this is the construct, the library will be added for all the pages of this controller.
*/
public function __construct()
{
parent::__construct(new HelpLibrary);
parent::__construct(new HelpService);

$this->_view->addLibrary('css', 'views/help/css/help.css');
}
Expand All @@ -45,7 +45,7 @@ public function index()
*/
public function helpMeWith($request)
{
$helpMessage = $this->_library->helpMeWith($request);
$helpMessage = $this->_service->helpMeWith($request);

$this->_view->setParameter('msg', $helpMessage);

Expand Down
10 changes: 7 additions & 3 deletions application/controllers/releaseLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@ public function __construct()
parent::__construct();

// Setting version under construction
$this->_setDevelopmentVersion('2.22', '04/01/2014', array(
$this->_setDevelopmentVersion('2.23', '04/01/2014', array(
'[Refactor] - Modified libraries concept to Service concepts. A Service is tightly related to a controller. It stores intelligence regarding what to do with validated information, which models request a CRUD, and informs the controller about the message to put into the related view.',
'[Refactor] - Modified Hecnel Framework in order to use the new Model architecture.'
));

// Setting Historical Log of releases
$this->_addHistoryLog('2.22', '04/01/2014', array(
'[Refactor] - Mayor change in Model architecture. Now all models extend the same Model object, which handles all commands that a Model offers and instantiates and communicates with the Database.',
'[Refactor] - Major change in Database architecture. Now it is allowed to have different storing systems.',
'[Feature] - New database system: Mock Database. Basically a database that always says yes, always returns data. For development purposes.',
'[Feature] - New Model Exception. When caught, its code indicates what happened. ',
'[Feature] - Connected Test3 to models. It allows CRUD to Dog, plus model exceptions catching and error display.'
));

// Setting Historical Log of releases
$this->_addHistoryLog('2.21', '03/01/2014', array(
'HAPPY NEW YEAR!!',
'[Feature] - Created basic skeleton for the new Model architecture.',
Expand Down
20 changes: 10 additions & 10 deletions application/controllers/usersManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
namespace application\controllers;

use application\engine\Controller;
use application\libraries\UsersManagementLibrary;
use application\services\UsersManagementService;
use engine\Input;
use engine\Session;
use engine\Form;

class usersManagement extends Controller
{
/**
* Defining $_library Library type.
* @var UsersManagementLibrary $_library
* Defining $_service Services type.
* @var UsersManagementService $_service
*/
protected $_library;
protected $_service;

/** Validates user access to this controller */
public function __construct()
{
parent::__construct(new UsersManagementLibrary);
parent::__construct(new UsersManagementService);

$logged = Session::get('isUserLoggedIn');
$userRole = Session::get('userRole');
Expand All @@ -40,7 +40,7 @@ public function __construct()
*/
public function index()
{
$this->_view->setParameter('usersList', $this->_library->getUsersList());
$this->_view->setParameter('usersList', $this->_service->getUsersList());

$this->_view->addChunk('usersManagement/index');
}
Expand All @@ -50,7 +50,7 @@ public function index()
*/
public function openUserEdition($userId)
{
$userData = $this->_library->getUser($userId);
$userData = $this->_service->getUser($userId);

if ($userData === FALSE) {
$this->_view->setParameter('error', 'The user you are trying to edit does not exist.');
Expand Down Expand Up @@ -88,7 +88,7 @@ public function createUser()
))
);

$this->_library->createUser(
$this->_service->createUser(
$form->getInput('userName')->getValue(),
$form->getInput('password')->getValue(),
$form->getInput('userRole')->getValue());
Expand Down Expand Up @@ -125,7 +125,7 @@ public function editUser()
))
);

$this->_library->editUser(
$this->_service->editUser(
$form->getInput('userId')->getValue(),
$form->getInput('userName')->getValue(),
$form->getInput('password')->getValue(),
Expand All @@ -141,7 +141,7 @@ public function editUser()
*/
public function deleteUser($userId)
{
$this->_library->deleteUser($userId);
$this->_service->deleteUser($userId);

header('location: ' . _SYSTEM_BASE_URL . 'usersManagement');
exit;
Expand Down
6 changes: 3 additions & 3 deletions application/engine/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class Controller extends engineController
/**
* Controller constructor.
*
* @param Library $library in which this Controller can search for the Model
* @param Service $service in which this Controller can search for the Model
*/
public function __construct(Library $library = NULL)
public function __construct(Service $service = NULL)
{
parent::__construct($library);
parent::__construct($service);
}

/**
Expand Down
20 changes: 0 additions & 20 deletions application/engine/Library.php

This file was deleted.

20 changes: 20 additions & 0 deletions application/engine/Service.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* Project: Hecnel Framework
* User: Hector Ordonez
* Description:
* Service class of the application engine.
* Date: 11/07/13 16:00
*/

namespace application\engine;

use engine\Service as engineService;

class Service extends engineService
{
public function __construct()
{
parent::__construct();
}
}
43 changes: 0 additions & 43 deletions application/libraries/DashboardLibrary.php

This file was deleted.

48 changes: 0 additions & 48 deletions application/libraries/LoginLibrary.php

This file was deleted.

Loading

0 comments on commit 1132965

Please sign in to comment.