本文整理汇总了PHP中ControllerFactory类的典型用法代码示例。如果您正苦于以下问题:PHP ControllerFactory类的具体用法?PHP ControllerFactory怎么用?PHP ControllerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ControllerFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/** Lance le serveur */
function run()
{
// racine du serveur a enregistrer qq part (pour l'instant ici)
$root = '/blogmarks/servers/atom';
// On construit le tableau d'arguments pour les filtres
$args = array();
// on extrait l'URI relative
$uri = $_SERVER['REQUEST_URI'];
//***** DEBUG echo $uri."<br/>".$root;
$uri = ereg_replace($root, '', $uri);
$args['uri'] = $uri;
$args['method'] = $_SERVER['REQUEST_METHOD'];
$args['content'] = $_GLOBALS['HTTP_RAW_POST_DATA'];
// On filtre la requête
$filter = new FilterChainRoot(array(new ContextBuilderFilter(), new AuthenticateFilter()));
$ret = $filter->execute(&$args);
if (BlogMarks::isError($ret)) {
// erreur de filtre
echo $ret->getMessage();
return;
}
// **** DEBUG
echo "objet : " . $args['object'] . "<br/>";
echo "method : " . $args['method'] . "<br/>";
echo "tag : " . $args['tag'] . "<br/>";
echo "user : " . $args['user'] . "<br/>";
echo "id : " . $args['id'] . "<br/>";
echo "auth_str :" . $args['auth_str'] . "<br/>";
// **********
// On construit le controlleur selon le type d'objet de la requête
$ctrlerFactory = new ControllerFactory();
$ctrler = $ctrlerFactory->createController($args['object']);
if (BlogMarks::isError($ctrler)) {
echo $ctrler->getMessage();
exit(1);
}
// On lance le controlleur pour l'objet de la requête
$response = $ctrler->execute($args);
if (BlogMarks::isError($response)) {
// erreur du controlleur de requête
return;
}
// On applique le renderer atom a la reponse et on la renvoit
$rendererFactory = new rendererFactory();
$renderer = $rendererFactory->createRenderer($args['object']);
// GERER LA REPONSE HTTP
echo "HTTP/1.1 200 Ok\n";
$response->accept($renderer);
echo $renderer->render();
}
示例2: execute
/**
* Perform execution of the application. This method is called from index2.php
*/
function execute()
{
global $sugar_config;
if (!empty($sugar_config['default_module'])) {
$this->default_module = $sugar_config['default_module'];
}
$module = $this->default_module;
if (!empty($_REQUEST['module'])) {
$module = $_REQUEST['module'];
}
insert_charset_header();
$this->setupPrint();
$this->controller = ControllerFactory::getController($module);
// if the entry point is defined to not need auth, then don't authenicate
if (empty($_REQUEST['entryPoint']) || $this->controller->checkEntryPointRequiresAuth($_REQUEST['entryPoint'])) {
$this->loadUser();
$this->ACLFilter();
$this->preProcess();
$this->controller->preProcess();
}
if (ini_get('session.auto_start') !== false) {
$_SESSION['breadCrumbs'] = new BreadCrumbStack($GLOBALS['current_user']->id);
}
SugarThemeRegistry::buildRegistry();
$this->loadLanguages();
$this->checkDatabaseVersion();
$this->loadDisplaySettings();
$this->loadLicense();
$this->loadGlobals();
$this->setupResourceManagement($module);
$this->controller->execute();
sugar_cleanup();
}
示例3: execute
/**
* Perform execution of the application. This method is called from index2.php
*/
function execute()
{
global $sugar_config;
if (!empty($sugar_config['default_module'])) {
$this->default_module = $sugar_config['default_module'];
}
$module = $this->default_module;
if (!empty($_REQUEST['module'])) {
$module = $_REQUEST['module'];
}
insert_charset_header();
$this->setupPrint();
$this->controller = ControllerFactory::getController($module);
// If the entry point is defined to not need auth, then don't authenticate.
if (empty($_REQUEST['entryPoint']) || $this->controller->checkEntryPointRequiresAuth($_REQUEST['entryPoint'])) {
$this->loadUser();
$this->ACLFilter();
$this->preProcess();
$this->controller->preProcess();
$this->checkHTTPReferer();
}
SugarThemeRegistry::buildRegistry();
$this->loadLanguages();
$this->checkDatabaseVersion();
$this->loadDisplaySettings();
//$this->loadLicense();
$this->loadGlobals();
$this->setupResourceManagement($module);
$this->controller->execute();
sugar_cleanup();
}
示例4: dispatch
public function dispatch()
{
$helper = HelperFactory::getHelper("Http");
$conf = $helper->parseGet($_GET);
try {
$staticRoute = $this->getCotrollerByAlias(ucfirst($conf["controller"]));
if ($staticRoute !== false) {
$conf["controller"] = $staticRoute['controller'];
if ($staticRoute['action'] != '') {
$conf["action"] = $staticRoute['action'];
}
}
$controller = ControllerFactory::getController(ucfirst($conf["controller"]));
$controller->applyFilters($conf);
$action = $conf["action"] . "Action";
$controller->startUp($conf);
call_user_func_array(array($controller, $action), $conf["param"]);
$controller->render($conf["action"]);
} catch (Doctrine_Connection_Exception $e) {
exit($e->getMessage());
ErrorHandler::displayError("Found a Doctrine connection error.<br>\n\t\t\t\t\t\t\t\t\t \tMake suere that you have started the Doctrine\n\t\t\t\t\t\t\t\t\t \tsubsystem.<br>");
} catch (MissingControllerException $e) {
exit("<h1>ERROR</h1><br><h2>Missing Controller</h2>");
} catch (MissingClassException $e) {
exit("<h1>ERROR</h1><br><h2>Missing class</h2>");
} catch (Exception $e) {
exit($e->getMessage());
$controller = ControllerFactory::getController("_404");
$controller->startUp();
$controller->render("index");
}
}
示例5: dispatch
private static function dispatch()
{
$control_name = CONTROLLER_NAME . 'Controller';
$action_name = ACTION_NAME . 'Action';
$factory = ControllerFactory::getInstance();
$controller = $factory->getController($control_name);
$controller->{$action_name}();
}
示例6: testControllerNameFromClass
function testControllerNameFromClass()
{
$this->assertEqual(ControllerFactory::get_controller_name_from_class("FPDFController"), "fpdf", "Il nome del controller non corrisponde! : " . ControllerFactory::get_controller_name_from_class("FPDFController"));
$this->assertEqual(ControllerFactory::get_controller_name_from_class("FPDFStaticController"), "fpdf_static", "Il nome del controller non corrisponde! : " . ControllerFactory::get_controller_name_from_class("FPDFStaticController"));
$this->assertEqual(ControllerFactory::get_controller_name_from_class("StaticRSSController"), "static_rss", "Il nome del controller non corrisponde! : " . ControllerFactory::get_controller_name_from_class("StaticRSSController"));
$this->assertEqual(ControllerFactory::get_controller_name_from_class("PippoPlutoController"), "pippo_pluto", "Il nome del controller non corrisponde! : " . ControllerFactory::get_controller_name_from_class("PippoPlutoController"));
$this->assertEqual(ControllerFactory::get_controller_name_from_class("Pippo_PlutoController"), "pippo_pluto", "Il nome del controller non corrisponde! : " . ControllerFactory::get_controller_name_from_class("pippo_plutoController"));
$this->assertEqual(ControllerFactory::get_controller_name_from_class("__Pippo__PlutoController"), "__pippo_pluto", "Il nome del controller non corrisponde! : " . ControllerFactory::get_controller_name_from_class("__pippo__plutoController"));
}
示例7: getInstance
public static function getInstance()
{
if (self::$instance == null) {
self::$instance = new ControllerFactory();
return self::$instance;
} else {
return self::$instance;
}
}
示例8: process
public function process()
{
try {
$request = new Request();
$action = ControllerFactory::runAction($request);
} catch (Exception $e) {
echo $e->getMessage();
}
}
示例9: Begin
public function Begin() {
$url = $_GET;
/**
* pseudocode:
* $url = split($_GET, '/');
* $controllerName = $url[0];
* $actionName = $url[1];
* $queryParams = $url[2...];
**/
$controllerFactory = new ControllerFactory();
$controller = $controllerFactory->CreateController($controllerName, $actionName);
$controller->OnActionExecuting();
$controller->ExecuteAction($queryParams);
$controller->OnActionExecuted();
}
示例10: run
public function run()
{
//Nécessaire pour l'affichage de la vue
include_once 'Models/Template.php';
include_once 'Models/Model.php';
include_once 'functions.php';
//Création de controlleur----------------------------
include_once 'Controllers/ControllerFactory.php';
$controller = ControllerFactory::createController();
//On lance l'action
$action = self::getInstance()->getActionName($controller);
$controller->{$action}();
}
示例11: __construct
function __construct($controller_name, $action, $format, $params)
{
//vecchio setup, e' stata aggiunta la creazione del controller
$this->controller = ControllerFactory::create($controller_name);
//hack per supportare i vecchi mapping con "php".
//$format = DataFormatManager::getFormatString($format);
$this->__check_reserved_action($action);
if ($format !== "raw") {
$this->__check_protected_action($action, $format);
}
DataFormatManager::checkFormatSupported($format);
$this->action = $action;
$this->format = $format;
$this->params = $params;
$this->format_helper = DataFormatManager::getFormat($format);
$this->execute_action = true;
$this->action_result = null;
}
示例12: testIsControllerClass2
function testIsControllerClass2()
{
$this->assertTrue(ControllerFactory::is_controller_class("ErrorController"), "ErrorController non e' un controller!");
$this->assertTrue(ControllerFactory::is_controller_class("ModuliController"), "ModuliController non e' un controller!");
$this->assertFalse(ControllerFactory::is_controller_class("FolderPeer"), "FolderPeer e' un controller!!");
$this->assertFalse(ControllerFactory::is_controller_class("ImmaginiDO"), "ImmaginiDO e' un controller!!");
$this->assertFalse(ControllerFactory::is_controller_class("EventiPeer"), "EventiPeer e' un controller!!");
$this->assertFalse(ControllerFactory::is_controller_class("XMLBuilder"), "XMLBuilder e' un controller!!");
$this->assertFalse(ControllerFactory::is_controller_class("DataHolder"), "DataHolder e' un controller!!");
$this->assertFalse(ControllerFactory::is_controller_class("ArrayUtils"), "ArrayUtils e' un controller!!");
$this->assertFalse(ControllerFactory::is_controller_class("ProfileMap"), "ProfileMap e' un controller!!");
$this->assertFalse(ControllerFactory::is_controller_class("PageLoader"), "PageLoader e' un controller!!");
$this->assertFalse(ControllerFactory::is_controller_class("ModulePlug"), "ModulePlug e' un controller!!");
$this->assertFalse(ControllerFactory::is_controller_class("FileWriter"), "FileWriter e' un controller!!");
$this->assertFalse(ControllerFactory::is_controller_class("FormWriter"), "FormWriter e' un controller!!");
$this->assertFalse(ControllerFactory::is_controller_class("RouteMatch"), "RouteMatch e' un controller!!");
$this->assertFalse(ControllerFactory::is_controller_class("EpiTwitter"), "EpiTwitter e' un controller!!");
$this->assertFalse(ControllerFactory::is_controller_class("Securimage"), "Securimage e' un controller!!");
$this->assertFalse(ControllerFactory::is_controller_class("AjaxHelper"), "AjaxHelper e' un controller!!");
}
示例13: display
function display()
{
global $mod_strings, $export_module, $current_language, $theme, $current_user;
echo get_module_title("Activities", $mod_strings['LBL_MODULE_TITLE'], true);
$mod_strings = return_module_language($current_language, 'Calls');
// Overload the export module since the user got here by clicking the "Activities" tab
$export_module = "Calls";
$_REQUEST['module'] = 'Calls';
$controller = ControllerFactory::getController('Calls');
$controller->loadBean();
$controller->preProcess();
$controller->process();
//Manipulate view directly to not display header, js and footer again
$view = ViewFactory::loadView($controller->view, $controller->module, $controller->bean, $controller->view_object_map);
$view->options['show_header'] = false;
$view->options['show_title'] = false;
$view->options['show_javascript'] = false;
$view->process();
die;
}
示例14: run
public function run()
{
require dirname(__FILE__) . '/init.php';
try {
ConfLoader::loadConfig();
$context = ApplicationContext::getContext();
$map = $context->getControllerMap();
$url = new Url();
$actionMap = $map->getAction($url->getPackage(), $url->getAction());
$controller = ControllerFactory::Create($actionMap['class']);
$actionAppointer = ActionAppointer::getInstance();
$actionAppointer->setController($controller);
$actionAppointer->appointer($actionMap);
} catch (FileException $fe) {
$fe->getTraceAsString();
} catch (CheckedException $ce) {
$ce->getTraceAsString();
} catch (Exception $e) {
$e->getTraceAsString();
}
}
示例15: validate
private static function validate($name)
{
try {
$url = URL::getInstance();
if ($name == null) {
if (Session::getInstance()->isStarted()) {
$url->setController(DEFAULT_SESSION_CONTROLLER);
$url->setAction(DEFAULT_SESSION_ACTION);
return DEFAULT_SESSION_CONTROLLER;
} else {
$url->setController(DEFAULT_REQUEST_CONTROLLER);
$url->setAction(DEFAULT_REQUEST_ACTION);
return DEFAULT_REQUEST_CONTROLLER;
}
}
$controller = $name . CONTROLLER;
$class = new ReflectionClass($controller);
if ($class->isAbstract()) {
throw new LogicException();
}
$classScope = $class->getConstant('SCOPE');
if ($class->implementsInterface('Context')) {
if (Scope::isAcceptable($classScope)) {
return $name;
}
if ($classScope == Scope::SESSION) {
$url->setController(DEFAULT_REQUEST_CONTROLLER);
$url->setAction(DEFAULT_REQUEST_ACTION);
return DEFAULT_REQUEST_CONTROLLER;
}
if ($classScope == Scope::REQUEST) {
ControllerFactory::create(DEFAULT_APPLICATION_CONTROLLER)->redirectToError();
}
}
return DEFAULT_APPLICATION_CONTROLLER;
} catch (LogicException $e) {
$e->getTraceAsString();
ControllerFactory::create(DEFAULT_APPLICATION_CONTROLLER)->redirectToError();
}
}