本文整理汇总了PHP中Zend_Controller_Request_Http::setPathInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Http::setPathInfo方法的具体用法?PHP Zend_Controller_Request_Http::setPathInfo怎么用?PHP Zend_Controller_Request_Http::setPathInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Request_Http
的用法示例。
在下文中一共展示了Zend_Controller_Request_Http::setPathInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setPathInfo
public function setPathInfo($pathInfo = null)
{
parent::setPathInfo($pathInfo);
$path = $this->_pathInfo;
$paths = explode('/', trim($path, '/'));
$language = !empty($paths[0]) ? $paths[0] : '';
if (in_array($language, Core_Model_Language::getLanguageCodes())) {
$this->_language_code = $language;
unset($paths[array_search($language, $paths)]);
$paths = array_values($paths);
}
if (!$this->isInstalling()) {
if (!empty($paths[0]) and $paths[0] == Application_Model_Application::OVERVIEW_PATH) {
$this->_is_application = true;
$this->_use_application_key = true;
unset($paths[0]);
}
if (Application_Model_Application::getInstance()->getDomain() == $this->getHttpHost()) {
$this->_is_application = true;
$this->_use_application_key = false;
}
}
$paths = array_diff($paths, Core_Model_Language::getLanguageCodes());
$paths = array_values($paths);
$this->_pathInfo = '/' . implode('/', $paths);
return $this;
}
示例2: rewrite
/**
* @test
* @loadFixture product
* @loadFixture questions
*/
public function rewrite()
{
$request = new Zend_Controller_Request_Http();
$response = new Zend_Controller_Response_Http();
$request->setPathInfo('productquestions/index/index/id/12/category/2/-questions.html');
$result = $this->_data->rewrite($request, $response);
$this->assertEquals(false, $result);
}
示例3: testMatch
/**
* @magentoAppIsolation enabled
*/
public function testMatch()
{
$request = new Zend_Controller_Request_Http();
//Open Node
$request->setPathInfo('parent_node');
$controller = $this->_model->match($request);
$this->assertInstanceOf('Mage_Core_Controller_Varien_Action_Redirect', $controller);
}
示例4: match
/**
* Match with router
*
* @param Zend_Controller_Request_Http $request
* @return boolean
*/
public function match(Zend_Controller_Request_Http $request)
{
$path = trim($request->getPathInfo(), '/');
if (strrpos($path, '.json') === strlen($path) - 5) {
$request->setPathInfo(substr($path, 0, strlen($path) - 5));
Mage::getSingleton('easyAjax/core')->setEasyAjax(true);
return parent::match($request);
}
return false;
}
示例5: indexAction
public function indexAction()
{
if (!($guid = $this->_getParam('guid')) || !($resource = Engine_Api::_()->getItemByGuid($guid))) {
return $this->_helper->viewRenderer()->setNoRender();
}
$router = Zend_Controller_Front::getInstance()->getRouter();
$req = new Zend_Controller_Request_Http();
$req->setPathInfo($resource->getHref());
$req = $router->route($req);
$this->_forward($req->getActionName(), $req->getControllerName(), $req->getModuleName(), $req->getParams());
}
示例6: forwardShopby
protected function forwardShopby()
{
$reservedKey = Mage::getStoreConfig('amshopby/seo/key');
$realModule = 'Amasty_Shopby';
$this->request->setPathInfo($reservedKey);
$this->request->setModuleName('amshopby');
$this->request->setRouteName('amshopby');
$this->request->setControllerName('index');
$this->request->setActionName('index');
$this->request->setControllerModule($realModule);
$file = Mage::getModuleDir('controllers', $realModule) . DS . 'IndexController.php';
include $file;
//compatibility with 1.3
$class = $realModule . '_IndexController';
$controllerInstance = new $class($this->request, $this->getFront()->getResponse());
$this->request->setDispatched(true);
$controllerInstance->dispatch('index');
}
示例7: match
/**
* Matches a user submitted path with a previously defined route.
* Assigns and returns an array of defaults on a successful match.
*
* @param Zend_Controller_Request_Http $request Request to get the path info from
* @return array|false An array of assigned values or a false on a mismatch
*/
public function match($request, $partial = null)
{
$path = trim($request->getPathInfo(), self::URI_DELIMITER);
$subPath = $path;
$values = array();
$numRoutes = count($this->_routes);
foreach ($this->_routes as $key => $route) {
if ($key > 0 && $matchedPath !== null && $subPath !== '' && $subPath !== false) {
$separator = substr($subPath, 0, strlen($this->_separators[$key]));
if ($separator !== $this->_separators[$key]) {
return false;
}
$subPath = substr($subPath, strlen($separator));
}
// TODO: Should be an interface method. Hack for 1.0 BC
if (!method_exists($route, 'getVersion') || $route->getVersion() == 1) {
$match = $subPath;
} else {
$request->setPathInfo($subPath);
$match = $request;
}
$res = $route->match($match, true, $key == $numRoutes - 1);
if ($res === false) {
return false;
}
$matchedPath = $route->getMatchedPath();
if ($matchedPath !== null) {
$subPath = substr($subPath, strlen($matchedPath));
$separator = substr($subPath, 0, strlen($this->_separators[$key]));
}
$values = $res + $values;
}
$request->setPathInfo($path);
if ($subPath !== '' && $subPath !== false) {
return false;
}
return $values;
}
示例8: _rewriteConfig
/**
* Apply configuration rewrites to current url
*
* @return bool
*/
protected function _rewriteConfig()
{
$config = $this->_config->getNode('global/rewrite');
if (!$config) {
return false;
}
foreach ($config->children() as $rewrite) {
$from = (string) $rewrite->from;
$to = (string) $rewrite->to;
if (empty($from) || empty($to)) {
continue;
}
$from = $this->_processRewriteUrl($from);
$to = $this->_processRewriteUrl($to);
$pathInfo = preg_replace($from, $to, $this->_request->getPathInfo());
if (isset($rewrite->complete)) {
$this->_request->setPathInfo($pathInfo);
} else {
$this->_request->rewritePathInfo($pathInfo);
}
}
return true;
}
示例9: setPathInfo
public function setPathInfo($pathInfo = null)
{
parent::setPathInfo($pathInfo);
$path = $this->_pathInfo;
$paths = explode('/', trim($path, '/'));
$language = !empty($paths[0]) ? $paths[0] : '';
if (in_array($language, Core_Model_Language::getLanguageCodes())) {
$this->_language_code = $language;
unset($paths[0]);
$paths = array_values($paths);
}
if (!$this->isInstalling()) {
$paths = $this->_initApplication($paths);
if (!$this->isApplication()) {
$this->_initWhiteLabelEditor();
}
}
// $paths = array_diff($paths, Core_Model_Language::getLanguageCodes());
$paths = array_values($paths);
$this->_pathInfo = '/' . implode('/', $paths);
$detector = new Mobile_Detect();
$this->_is_native = $detector->isNative();
return $this;
}
示例10: match
public function match(Zend_Controller_Request_Http $request)
{
if (Mage::app()->getStore()->isAdmin()) {
return false;
}
$pageId = $request->getPathInfo();
// remove suffix if any
$suffix = Mage::helper('amshopby/url')->getUrlSuffix();
if ($suffix && '/' != $suffix) {
$pageId = str_replace($suffix, '', $pageId);
}
//add trailing slash
$pageId = trim($pageId, '/') . '/';
$reservedKey = Mage::getStoreConfig('amshopby/seo/key') . '/';
// canon/
// electronics - false
// electronics/shopby/canon/
// electronics/shopby/red/
// electronics/shopby/
// shopby/
// shopby/red/
// shopby/canon/ - false
// shopby/manufacturer-canon/ - false
// manufacturer-canon/ - true
// starts from shopby
$isAllProductsPage = substr($pageId, 0, strlen($reservedKey)) == $reservedKey;
// has shopby in the middle
$isCategoryPage = false !== strpos($pageId, '/' . $reservedKey);
if (!Mage::getStoreConfig('amshopby/seo/urls')) {
// If path info have something after reserved key
if (($isAllProductsPage || $isCategoryPage) && substr($pageId, -strlen($reservedKey), strlen($reservedKey)) != $reservedKey) {
return false;
}
}
if ($isAllProductsPage) {
// no support for old style urls
if ($this->hasBrandIn(self::MIDDLE, $pageId)) {
return false;
}
}
if (!$isAllProductsPage && !$isCategoryPage) {
if (!$this->hasBrandIn(self::BEGINNING, $pageId)) {
return false;
}
//it is brand page and we modify the url to be in the old style
$pageId = $reservedKey . $pageId;
}
// get layered navigation params as string
list($cat, $params) = explode($reservedKey, $pageId, 2);
$params = trim($params, '/');
if ($params) {
$params = explode('/', $params);
}
// remember for futire use in the helper
if ($params) {
Mage::register('amshopby_current_params', $params);
}
$cat = trim($cat, '/');
if ($cat) {
// normal category
// if somebody has old urls in the cache.
if (!Mage::getStoreConfig('amshopby/seo/urls')) {
return false;
}
// we do not use Mage::getVersion() here as it is not defined in the old versions.
$isVersionEE13 = 'true' == (string) Mage::getConfig()->getNode('modules/Enterprise_UrlRewrite/active');
if ($isVersionEE13) {
$urlRewrite = Mage::getModel('enterprise_urlrewrite/url_rewrite');
/* @var $urlRewrite Enterprise_UrlRewrite_Model_Url_Rewrite */
if (version_compare(Mage::getVersion(), '1.13.0.2', '>=')) {
$catReqPath = array('request' => $cat . $suffix, 'whole' => $cat);
} else {
$catReqPath = array($cat);
}
$urlRewrite->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($catReqPath);
} else {
$urlRewrite = Mage::getModel('core/url_rewrite');
/* @var $urlRewrite Mage_Core_Model_Url_Rewrite */
$cat = $cat . $suffix;
$catReqPath = $cat;
$urlRewrite->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($catReqPath);
}
// todo check in ee13
if (!$urlRewrite->getId()) {
$store = $request->getParam('___from_store');
$store = Mage::app()->getStore($store)->getId();
if (!$store) {
return false;
}
$urlRewrite->setData(array())->setStoreId($store)->loadByRequestPath($catReqPath);
if (!$urlRewrite->getId()) {
return false;
}
}
$request->setPathInfo($cat);
$request->setModuleName('catalog');
$request->setControllerName('category');
$request->setActionName('view');
if ($isVersionEE13) {
$categoryId = str_replace('catalog/category/view/id/', '', $urlRewrite->getTargetPath());
//.........这里部分代码省略.........
示例11: testChainingWithConfiguredEmptyStaticRoutesMatchesCorrectly
/**
* @group ZF-7848
*/
public function testChainingWithConfiguredEmptyStaticRoutesMatchesCorrectly()
{
$routes = array('admin' => array('route' => 'admin', 'defaults' => array('module' => 'admin', 'controller' => 'index', 'action' => 'index'), 'chains' => array('index' => array('type' => 'Zend_Controller_Router_Route_Static', 'route' => '', 'defaults' => array('module' => 'admin', 'controller' => 'index', 'action' => 'index')), 'login' => array('route' => 'login', 'defaults' => array('module' => 'admin', 'controller' => 'login', 'action' => 'index')))));
$config = new Zend_Config($routes);
$rewrite = new Zend_Controller_Router_Rewrite();
$rewrite->addConfig($config);
$routes = $rewrite->getRoutes();
$indexRoute = $rewrite->getRoute('admin-index');
$loginRoute = $rewrite->getRoute('admin-login');
$request = new Zend_Controller_Request_Http();
$request->setPathInfo('/admin');
$values = $indexRoute->match($request);
$this->assertEquals(array('module' => 'admin', 'controller' => 'index', 'action' => 'index'), $values);
$request->setPathInfo('/admin/');
$values = $indexRoute->match($request);
$this->assertEquals(array('module' => 'admin', 'controller' => 'index', 'action' => 'index'), $values);
$request->setPathInfo('/admin/login');
$values = $loginRoute->match($request);
$this->assertEquals(array('module' => 'admin', 'controller' => 'login', 'action' => 'index'), $values);
}
示例12: getSEORequest
function getSEORequest($uri)
{
$request = new Zend_Controller_Request_Http($uri);
$request->setPathInfo($uri);
return $request;
}
开发者ID:ngagestudios,项目名称:magento.vehiclefits.com,代码行数:6,代码来源:Elite_Vafsitemap_Model_Url_RewriteTests_TestCase.php
示例13: getOriginalRequest
public function getOriginalRequest()
{
$request = new Zend_Controller_Request_Http();
$request->setPathInfo($this->getOriginalPathInfo());
return $request;
}
示例14: testSetPathInfo
public function testSetPathInfo()
{
$this->_request->setPathInfo('/archives/past/4');
$this->assertEquals('/archives/past/4', $this->_request->getPathInfo());
}
示例15: isRouteAllowed
/**
* Checks if the role is allowed to access the given route.
*
* @param Zend_Controller_Router_Route|string $route A route or route name.
* @param array $data Optional parameters to assemble the route.
* @param mixed $privilege An optional privilege.
*
* @return bool If the role is allowed to access the given route.
*/
public function isRouteAllowed($route, array $data = array(), $privilege = null)
{
$router = Zend_Controller_Front::getInstance()->getRouter();
if (!$route instanceof Zend_Controller_Router_Route) {
$route = $router->getRoute((string) $route);
}
$request = new Zend_Controller_Request_Http();
$request->setPathInfo($route->assemble($data));
$router->route($request);
return $this->isRequestAllowed($request, $privilege);
}