本文整理汇总了PHP中FrontController类的典型用法代码示例。如果您正苦于以下问题:PHP FrontController类的具体用法?PHP FrontController怎么用?PHP FrontController使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FrontController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleException
public static function handleException($e)
{
$fc = new FrontController();
$page = new Page('error/500', $fc);
$page->process();
$fc->getResponse()->send();
}
示例2: testExecute
/**
* Configure ACL to deny everything, thus the request must be dispatched
* to the authentication controller.
*
* @covers spriebsch\MVC\FrontController
*/
public function testExecute()
{
$this->request = $this->getMock('spriebsch\\MVC\\Request', array(), array(), '', false, false);
$this->response = $this->getMock('spriebsch\\MVC\\Response', array(), array(), '', false, false);
$this->session = $this->getMock('spriebsch\\MVC\\Session', array(), array(), '', false, false);
$this->authAdapter = $this->getMock('spriebsch\\MVC\\AuthenticationAdapter', array(), array(), '', false, false);
$this->controllerFactory = $this->getMock('spriebsch\\MVC\\ControllerFactory', array(), array(), '', false, false);
$this->viewFactory = $this->getMock('spriebsch\\MVC\\ViewFactory', array(), array(), '', false, false);
$this->acl = $this->getMock('spriebsch\\MVC\\Acl', array(), array(), '', false, false);
$this->appController = $this->getMock('spriebsch\\MVC\\ApplicationController', array(), array(), '', false, false);
$this->view = $this->getMock('spriebsch\\MVC\\View', array(), array(), '', false, false);
$this->controller = $this->getMock('spriebsch\\MVC\\Controller', array(), array(), '', false, false);
// Controller's execute method must be called once and return 'success'.
$this->controller->expects($this->once())->method('execute')->will($this->returnValue('success'));
// View's render method must be called once.
$this->view->expects($this->once())->method('render');
// ->with($this->equalTo());
// @todo request and response as parameters
// The controller factory returns the controller object.
$this->controllerFactory->expects($this->once())->method('getController')->will($this->returnValue($this->controller));
// The application controller returns a controller name, class, and
// method that we ignore anyway.
$this->appController->expects($this->once())->method('getControllerName')->will($this->returnValue('controller'));
$this->appController->expects($this->once())->method('getClass')->will($this->returnValue('class'));
$this->appController->expects($this->once())->method('getMethod')->will($this->returnValue('method'));
$this->appController->expects($this->once())->method('getView')->will($this->returnValue($this->view));
$fc = new FrontController($this->request, $this->response, $this->session, $this->authAdapter, $this->acl, $this->appController, $this->controllerFactory);
$fc->execute();
}
示例3: testDispatchingWorksCorrectly
/**
* @covers FrontController::__construct
* @covers FrontController::dispatch
*/
public function testDispatchingWorksCorrectly()
{
$request = new Request(array('REQUEST_URI' => '/test'));
$response = new Response();
$router = new Router();
$router->set('test', 'TestController');
$frontController = new FrontController($request, $response, $router, new ControllerFactory(new MapperFactory(new PDO('sqlite::memory:'))), new ViewFactory());
$this->assertInstanceOf('TestView', $frontController->dispatch($router));
}
示例4: indexAction
public function indexAction()
{
$fc = FrontController::getInstance();
$view = new DefaultModel();
$out = $view->showIndexPage();
$fc->setBody($out);
}
示例5: getInstance
public static function getInstance()
{
if (!is_object(self::$_instance)) {
self::$_instance = new FrontController();
}
return self::$_instance;
}
示例6: run
public function run()
{
if ($this->getConfigFolder() == null) {
$this->setConfigFolder('../config');
}
$this->frontController = FrontController::getInstance();
if ($this->router == null) {
$this->router = new DefaultRouter();
}
$this->frontController->setRouter($this->router);
$sess = $this->config->app['session'];
if (isset($sess['autostart'])) {
if ($sess['type'] == 'native') {
$s = new NativeSession($sess['name'], $sess['lifetime'], $sess['path'], $sess['domain'], $sess['secure']);
$http = new HttpContext(null, $s);
}
$this->setHttpContext($http ?? new HttpContext());
}
if (isset($this->config->app['identity']['userClass'])) {
$userConfigClass = $this->config->app['identity']['userClass'];
$this->identity = new Identity($userConfigClass, new SimpleDB());
} else {
$this->identity = new Identity(new IdentityUser(null, null), new SimpleDB());
}
$this->frontController->dispatch();
}
示例7: __construct
public function __construct()
{
$fc = FrontController::getInstance();
$this->params = $fc->getParams();
$this->format = $fc->getFormat();
$this->makeObj();
}
示例8: getInstance
/**
* Returns an instance of FrontController object
* @return FrontController
*/
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = new self();
}
return self::$instance;
}
示例9: getSubCategories
public static function getSubCategories($id_lang, $active = true, $id_category = 2, $p = 0, $n = 6)
{
$sql_groups_where = '';
$sql_groups_join = '';
if (Group::isFeatureActive()) {
$sql_groups_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cg.`id_category` = c.`id_category`)';
$groups = FrontController::getCurrentCustomerGroups();
$sql_groups_where = 'AND cg.`id_group` ' . (count($groups) ? 'IN (' . pSQL(implode(',', $groups)) . ')' : '=' . (int) Group::getCurrent()->id);
}
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.*, cl.id_lang, cl.name, cl.description, cl.link_rewrite, cl.meta_title, cl.meta_keywords, cl.meta_description
FROM `' . _DB_PREFIX_ . 'category` c
' . Shop::addSqlAssociation('category', 'c') . '
LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category`
AND `id_lang` = ' . (int) $id_lang . ' ' . Shop::addSqlRestrictionOnLang('cl') . ')
' . $sql_groups_join . '
WHERE `id_parent` = ' . (int) $id_category . '
' . ($active ? 'AND `active` = 1' : '') . '
' . $sql_groups_where . '
GROUP BY c.`id_category`
ORDER BY `level_depth` ASC, category_shop.`position` ASC
LIMIT ' . (int) $p . ', ' . (int) $n);
foreach ($result as &$row) {
$row['id_image'] = Tools::file_exists_cache(_PS_CAT_IMG_DIR_ . $row['id_category'] . '.jpg') ? (int) $row['id_category'] : Language::getIsoById($id_lang) . '-default';
$row['legend'] = 'no picture';
}
return $result;
}
示例10: indexAction
public function indexAction()
{
$fc = FrontController::getInstance();
$admin = new Admin();
$output = $admin->render(ADMIN_TEMPLATE, ADMIN_LOGIN);
$fc->setBody($output);
}
示例11: indexAction
public function indexAction()
{
$fc = FrontController::getInstance();
$model = new PageModel();
header('HTTP/1.0 Not Found');
$fc->setBody($model->render('404.php', TEMPLATE));
}
示例12: run
public static function run($request)
{
if (!$request instanceof Request) {
$request = new Request($request);
}
$file = $request->getFile();
$class = $request->getClass();
$method = $request->getMethod();
$args = $request->getArgs();
$front = FrontController::getInstance();
$registry = $front->getRegistry();
$registry->oRequest = $request;
$front->setRegistry($registry);
if (file_exists($file)) {
require_once $file;
$rc = new ReflectionClass($class);
// if the controller exists and implements IController
// if($rc->implementsInterface('IController'))
if ($rc->isSubclassOf('BaseController')) {
try {
$controller = $rc->newInstance();
$classMethod = $rc->getMethod($method);
return $classMethod->invokeArgs($controller, $args);
} catch (ReflectionException $e) {
throw new MvcException($e->getMessage());
}
} else {
// throw new MvcException("Interface iController must be implemented");
throw new MvcException("abstract class BaseController must be extended");
}
} else {
throw new MvcException("Controller file not found");
}
}
示例13: showAll
public function showAll()
{
$fc = FrontController::getInstance();
$dbh = $fc->connect();
$sql = "\n\t\t\tSELECT listenerName, listenerTitle, status, moderatedTime\n\t\t\t\tFROM listener \n\t\t\t\t\tORDER by moderatedTime\n\t\t";
$sth = $dbh->prepare($sql);
$sth->execute();
$result = $sth->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $item) {
switch ($item['status']) {
case 0:
$status = "На модерации";
break;
case 1:
$status = "<span class='text-success'>Одобрено</span>";
break;
case 2:
$status = "<span class='text-danger'>Отклонено</span>";
break;
case 3:
$status = "<span class='text-info'>В архиве</span>";
break;
}
echo "<tr>\n\t\t\t\t\t<td>{$item['listenerName']}</td>\n\t\t\t\t\t<td>{$item['listenerTitle']}</td>\n\t\t\t\t\t<td>{$status}</td>\n\t\t\t\t\t<td>";
echo $item[moderatedTime] != 0 ? date("d-m-Y H:i:s", $item[moderatedTime]) : "";
echo "</td>\n\t\t\t\t</tr>";
}
}
示例14: getInstance
public static function getInstance()
{
if (self::$instance == false) {
self::$instance = new FrontController();
}
return self::$instance;
}
示例15: __construct
public function __construct($obj)
{
parent::__construct($obj);
$this->fc = FrontController::getInstance();
$this->error = '';
$this->isLoggedIn = $this->isLoggingOut = false;
}