本文整理汇总了PHP中Pimcore\Tool::getRoutingDefaults方法的典型用法代码示例。如果您正苦于以下问题:PHP Tool::getRoutingDefaults方法的具体用法?PHP Tool::getRoutingDefaults怎么用?PHP Tool::getRoutingDefaults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Tool
的用法示例。
在下文中一共展示了Tool::getRoutingDefaults方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _handleError
/**
* @param \Zend_Controller_Request_Abstract $request
* @throws mixed
*/
protected function _handleError(\Zend_Controller_Request_Abstract $request)
{
// remove zend error handler
$front = \Zend_Controller_Front::getInstance();
$front->unregisterPlugin("Zend_Controller_Plugin_ErrorHandler");
$response = $this->getResponse();
if ($response->isException() && !$this->_isInsideErrorHandlerLoop) {
// get errorpage
try {
// enable error handler
$front->setParam('noErrorHandler', false);
$errorPath = Config::getSystemConfig()->documents->error_pages->default;
if (Site::isSiteRequest()) {
$site = Site::getCurrentSite();
$errorPath = $site->getErrorDocument();
}
if (empty($errorPath)) {
$errorPath = "/";
}
$document = Document::getByPath($errorPath);
if (!$document instanceof Document\Page) {
// default is home
$document = Document::getById(1);
}
if ($document instanceof Document\Page) {
$params = Tool::getRoutingDefaults();
if ($module = $document->getModule()) {
$params["module"] = $module;
}
if ($controller = $document->getController()) {
$params["controller"] = $controller;
$params["action"] = "index";
}
if ($action = $document->getAction()) {
$params["action"] = $action;
}
$this->setErrorHandler($params);
$request->setParam("document", $document);
\Zend_Registry::set("pimcore_error_document", $document);
// ensure that a viewRenderer exists, and is enabled
if (!\Zend_Controller_Action_HelperBroker::hasHelper("viewRenderer")) {
$viewRenderer = new \Pimcore\Controller\Action\Helper\ViewRenderer();
\Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
}
$viewRenderer = \Zend_Controller_Action_HelperBroker::getExistingHelper("viewRenderer");
$viewRenderer->setNoRender(false);
if ($viewRenderer->view === null) {
$viewRenderer->initView(PIMCORE_WEBSITE_PATH . "/views");
}
}
} catch (\Exception $e) {
\Logger::emergency("error page not found");
}
}
// call default ZF error handler
parent::_handleError($request);
}
示例2: match
/**
* @param $path
* @param bool $partial
* @return array|bool
*/
public function match($path, $partial = false)
{
// this allows the usage of UTF8 URLs and within static routes
$path = urldecode($path);
$front = \Zend_Controller_Front::getInstance();
$matchFound = false;
$config = Config::getSystemConfig();
$routeingDefaults = Tool::getRoutingDefaults();
$params = array_merge($_GET, $_POST);
$params = array_merge($routeingDefaults, $params);
// set the original path
$originalPath = $path;
// check for password protection (http auth)
if ($config->general->http_auth) {
$username = $config->general->http_auth->username;
$password = $config->general->http_auth->password;
if ($username && $password) {
$adapter = new \Zend_Auth_Adapter_Http(array("accept_schemes" => "basic", "realm" => $_SERVER["HTTP_HOST"]));
$basicResolver = new \Pimcore\Helper\Auth\Adapter\Http\ResolverStatic($username, $password);
$adapter->setBasicResolver($basicResolver);
$adapter->setRequest($front->getRequest());
$adapter->setResponse($front->getResponse());
$result = $adapter->authenticate();
if (!$result->isValid()) {
// Bad userame/password, or canceled password prompt
echo "Authentication Required";
$front->getResponse()->sendResponse();
exit;
}
}
}
// check for a registered site
try {
// do not initialize a site if it is a "special" admin request
if (!Tool::isFrontentRequestByAdmin()) {
$domain = Tool::getHostname();
$site = \Zend_Registry::isRegistered("pimcore_site") ? \Zend_Registry::get("pimcore_site") : Site::getByDomain($domain);
$path = $site->getRootPath() . $path;
\Zend_Registry::set("pimcore_site", $site);
}
} catch (\Exception $e) {
}
// test if there is a suitable redirect with override = all (=> priority = 99)
if (!$matchFound) {
$this->checkForRedirect(true);
}
// do not allow requests including /index.php/ => SEO
// this is after the first redirect check, to allow redirects in index.php?xxx
if (preg_match("@^/index.php(.*)@", $_SERVER["REQUEST_URI"], $matches) && strtolower($_SERVER["REQUEST_METHOD"]) == "get") {
$redirectUrl = $matches[1];
$redirectUrl = ltrim($redirectUrl, "/");
$redirectUrl = "/" . $redirectUrl;
header("Location: " . $redirectUrl, true, 301);
exit;
}
// redirect to the main domain if specified
try {
$hostRedirect = null;
if ($config->general->redirect_to_maindomain && $config->general->domain && $config->general->domain != Tool::getHostname() && !Site::isSiteRequest() && !Tool::isFrontentRequestByAdmin()) {
$hostRedirect = $config->general->domain;
}
if (Site::isSiteRequest()) {
$site = Site::getCurrentSite();
if ($site->getRedirectToMainDomain() && $site->getMainDomain() != Tool::getHostname()) {
$hostRedirect = $site->getMainDomain();
}
}
if ($hostRedirect && !isset($_GET["pimcore_disable_host_redirect"])) {
$url = ($front->getRequest()->isSecure() ? "https" : "http") . "://" . $hostRedirect . $_SERVER["REQUEST_URI"];
header("HTTP/1.1 301 Moved Permanently");
header("Location: " . $url, true, 301);
// log all redirects to the redirect log
\Pimcore\Log\Simple::log("redirect", Tool::getAnonymizedClientIp() . " \t Host-Redirect Source: " . $_SERVER["REQUEST_URI"] . " -> " . $url);
exit;
}
} catch (\Exception $e) {
}
// check for direct definition of controller/action
if (!empty($_REQUEST["controller"]) && !empty($_REQUEST["action"])) {
$matchFound = true;
//$params["document"] = $this->getNearestDocumentByPath($path);
}
// you can also call a page by it's ID /?pimcore_document=XXXX
if (!$matchFound) {
if (!empty($params["pimcore_document"]) || !empty($params["pdid"])) {
$doc = Document::getById($params["pimcore_document"] ? $params["pimcore_document"] : $params["pdid"]);
if ($doc instanceof Document) {
$path = $doc->getFullPath();
}
}
}
// test if there is a suitable page
if (!$matchFound) {
try {
$document = Document::getByPath($path);
//.........这里部分代码省略.........