#0 | Frontend\Prepare\Prepare->content(Object(Frontend\Models\Content: 13))
/var/www/html/apps/frontend/controllers/ControllerBase.php (90) <?php
namespace Frontend\Controllers;
use Phalcon\Mvc\Controller;
use Phalcon\Mvc\Dispatcher;
use Frontend\Models\Hierarchy;
use Frontend\Cart\Cart;
use Frontend\Models\Content;
use Frontend\Models\Location;
/*
* ControllerBase
* This is the base controller for all controllers in the application
*/
class ControllerBase extends Controller{
protected function initialize(){
$this->tag->prependTitle('TKS | ');
$this->view->setVar('lang', $this->getLang());
}
/*
* Execute before the router so we can determine if this is a private controller, and must be authenticated, or a public controller that is open to all.
*
* @param Dispatcher $dispatcher
* @return boolean
*/
public function beforeExecuteRoute(Dispatcher $dispatcher){
// get controller and action name
$this->session->set('moduleName',$dispatcher->getModuleName());
$this->session->set('controllerName', $dispatcher->getControllerName());
$this->session->set('actionName', $dispatcher->getActionName());
// instantiate language
$this->lang->initLang($this->dispatcher->getParam('lang'));
$this->view->setVars(array(
'langCode' => $this->session->get('langCode'),
'curURL' => $this->router->getRewriteUri()
));
$this->view->langCode = $this->session->get('langCode');
/*
*
*/
$controllerName = $dispatcher->getControllerName();
// Only check permissions on private controllers
if ($this->acl->isPrivate($controllerName)) {
// Get the current identity
$identity = $this->auth->getIdentity();
// If there is no identity available the user is redirected to index/index
if (!is_array($identity)) {
$this->flashSession->notice('You don\'t have access to this section.');
$this->response->redirect('/session/login');
return false;
}
// Check if the user have permission to the current option
$actionName = $dispatcher->getActionName();
if (!$this->acl->isAllowed($identity['profile'], $controllerName, $actionName)) {
$this->flash->notice('You don\'t have access to this module: ' . $controllerName . ':' . $actionName);
if ($this->acl->isAllowed($identity['profile'], $controllerName, 'index')) {
$dispatcher->forward(array(
'controller' => $controllerName,
'action' => 'index'
));
} else {
$dispatcher->forward(array(
'controller' => 'user_control',
'action' => 'index'
));
}
return false;
}
}
// load main menu
$this->view->mainMenu = $this->loadMainMenu();
$this->view->logo = $this->prepare->content(Content::findFirst("content_id = 21"));
$this->view->footerContact = $this->prepare->location(Location::findFirst("location_id = 1"));
$this->view->associatedCompanyData = Content::find(
array(
"category_id = 218 AND status_active = 'Y' ",
"order" => "content_id DESC",
"limit" => 3
)
);
$this->view->latestNewsData = Content::find(
array(
"category_id = 192 AND status_active = 'Y' ",
"order" => "content_id DESC",
"limit" => 3
)
);
// init cart
$cart = new Cart();
$cart->initCart();
}
/*
*
*/
protected function loadMainMenu(){
$hierarchy = new Hierarchy();
return $hierarchy->getHierarchyById(2);
}
/*
*
*/
protected function forward($uri){
$uriParts = explode('/', $uri);
$params = array_slice($uriParts, 2);
return $this->dispatcher->forward(
array(
'controller' => $uriParts[0],
'action' => $uriParts[1],
'params' => $params
)
);
}
/*
*
*/
protected function getLang(){
return new \Frontend\Lang\Database(array(
'db' => $this->di->get('db'), // Here we're getting the database from DI
'table' => $this->config->database->langTableName, // The table that is storing the translations
'language' => $this->session->get('langCode') // Now we're getting the best language for the user
));
}
protected function genQryByAry($field, $ary){
$qry = '';
if(!empty($ary)){
$qry .= '(';
foreach($ary as $value){
$qry .= "$field = $value OR ";
}
$qry = rtrim($qry,'OR ');
$qry .= ') AND ';
}
return $qry;
}
protected function printErrorMessage($obj, $options = array()){
$responseMessage = '';
foreach ($obj->getMessages() as $message) {
$responseMessage .= $message . "<br/>";
}
if(array_key_exists('prepend',$options)){
$responseMessage = $options['prepend'].'<br/>'.$responseMessage;
}else if(array_key_exists('append',$options)){
$responseMessage = $responseMessage.$options['append'];
}
$responseMessage = rtrim($responseMessage,'<br/>');
return $responseMessage;
}
}
|
#3 | Phalcon\Mvc\Application->handle()
/var/www/html/public/index.php (43) <?php
// php runtime configuration
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('opcache.enable', 0);
// start phalcon instantiation
use Phalcon\Mvc\Application;
use Phalcon\DI\FactoryDefault;
$di = new FactoryDefault();
// Specify routes for modules
$di->set('router', function(){
return require '../apps/routes.php';
});
try{
// Create an application
$application = new Application($di);
// Register the installed modules
$application->registerModules(
array(
'frontend' => array(
'className' => 'Frontend\Module',
'path' => '../apps/frontend/Module.php'
),
'backend' => array(
'className' => 'Backend\Module',
'path' => '../apps/backend/Module.php'
)
)
);
$debug = new \Phalcon\Debug();
$debug->listen();
// Handle the request
echo $application->handle()->getContent();
}catch(\Exception $e){
echo $e->getMessage();
}
?> |