Perforce Chronicle 2012.2/486814
API Documentation

P4Cms_Controller_Request_Http Class Reference

Extended version of the standard http request object with specialized knowledge of the convention for embedding a site branch name in path info (e.g. More...

List of all members.

Public Member Functions

 getBranchBaseUrl ()
 Get the base url with the branch embedded (if one is present).
 getBranchlessPath ()
 Get the request path info, but with the embedded branch name removed.
 getBranchName ()
 Get the branch name in this request's path info (if one is present).
 getPathInfo ()
 Extended to fix a problem where explicitly setting the path to an empty string always re-generated the path from server/environment variables.

Protected Attributes

 $_branch = false
 $_pathInfo = null

Detailed Description

Extended version of the standard http request object with specialized knowledge of the convention for embedding a site branch name in path info (e.g.

'/-dev-/module/controller/action').

See P4Cms_Site for additional information.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

P4Cms_Controller_Request_Http::getBranchBaseUrl ( )

Get the base url with the branch embedded (if one is present).

Returns:
string the base url including the branch id.
    {
        $baseUrl = trim($this->getBaseUrl(), '/');

        return $this->getBranchName()
            ? $baseUrl . '/-' . $this->getBranchName() . '-'
            : $baseUrl;
    }
P4Cms_Controller_Request_Http::getBranchlessPath ( )

Get the request path info, but with the embedded branch name removed.

Returns:
string the path info without the branch name.
    {
        $pattern = '#^/?-' . $this->getBranchName() . '-/?#';
        return preg_replace($pattern, '', $this->getPathInfo());
    }
P4Cms_Controller_Request_Http::getBranchName ( )

Get the branch name in this request's path info (if one is present).

For example: '/-dev-/path' would produce 'dev'.

Returns:
string the branch id or null if none specified.
    {
        if ($this->_branch === false) {
            $this->_branch = preg_match('#^/-([^/]+)-#', $this->getPathInfo(), $matches)
                ? $matches[1]
                : null;
        }

        return $this->_branch;
    }
P4Cms_Controller_Request_Http::getPathInfo ( )

Extended to fix a problem where explicitly setting the path to an empty string always re-generated the path from server/environment variables.

Returns:
string everything between the BaseUrl and QueryString.
    {
        if ($this->_pathInfo === null) {
            $this->setPathInfo();
        }

        return $this->_pathInfo;
    }

Member Data Documentation

P4Cms_Controller_Request_Http::$_branch = false [protected]
P4Cms_Controller_Request_Http::$_pathInfo = null [protected]

The documentation for this class was generated from the following file: