本文整理汇总了PHP中Authorization::setAuthorizationParams方法的典型用法代码示例。如果您正苦于以下问题:PHP Authorization::setAuthorizationParams方法的具体用法?PHP Authorization::setAuthorizationParams怎么用?PHP Authorization::setAuthorizationParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Authorization
的用法示例。
在下文中一共展示了Authorization::setAuthorizationParams方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* Upon invoking of the constructor, a few objects need to be created
* in order to approve, authorize and secure the action contexts.
*
* This constructor sets up the Security, ErrorContainer, Authorization
* and also sets the request parameters, files parameters, the format of the output
* and of course the most important part which is the action/output contexts themselves.
*
* @warning IF-Clusterfuck.
*
* @see Security
* @see ErrorContainer
* @see Authorization
* @params object $customAuthorization optional custom authorization extending Frapi_Authorization
*/
public function __construct($customAuthorization = null)
{
try {
$this->security = new Frapi_Security();
$this->authorization = $customAuthorization instanceof Frapi_Authorization ? $customAuthorization : new Frapi_Authorization();
$this->router = new Frapi_Router();
$this->router->loadAndPrepareRoutes();
$this->setInputFormat();
$uri = $_SERVER['REQUEST_URI'];
// For some reason, this is now a fatal
// error in 5.3 and no longer a warning
// in php (parse_url() with an http:// in the URL_PATH)...
if (stristr($uri, '?') !== false) {
$uri = substr($uri, 0, strpos($uri, '?'));
}
$query_path = parse_url($uri, PHP_URL_PATH);
// @deprecated The use of extensions is considered deprecated
//Query ending in .xxx may or may not be an output format
$query_path_format = pathinfo($query_path, PATHINFO_EXTENSION);
$format = $this->getParam('format');
if (is_string($query_path_format) && strlen($query_path_format) || $format) {
$extension = $query_path_format ? $query_path_format : $format;
if ($query_path_format) {
$query_path = substr($query_path, 0, (strlen($extension) + 1) * -1);
}
if (Frapi_Rules::validateOutputType($extension) === true) {
$accept = Frapi_Output::getMimeTypeByFormat($extension);
if (isset($_SERVER['HTTP_ACCEPT'])) {
$_SERVER['HTTP_ACCEPT'] = $accept . ',' . $_SERVER['HTTP_ACCEPT'];
} else {
$_SERVER['HTTP_ACCEPT'] = $accept;
}
}
$query_path_format = $format = null;
}
if ($routed = $this->router->match($query_path)) {
$_REQUEST = array_merge($_REQUEST, $routed['params']);
$this->setAction(strtolower($routed['action']));
$this->setRequest($_REQUEST);
} else {
$this->setRequest($_REQUEST);
$this->setAction($this->getParam('action'));
}
// assign the files and params from the request
$this->setFiles($_FILES)->setParams($this->request);
$this->authorization->setAuthorizationParams($this->getParams());
} catch (Frapi_Exception $e) {
// Something RONG happened. Need to tell developers.
throw $e;
} catch (Exception $e) {
// Something else? Silence! I Keeel you.
}
}
示例2: __construct
/**
* Constructor
*
* Upon invoking of the constructor, a few objects need to be created
* in order to approve, authorize and secure the action contexts.
*
* This constructor sets up the Security, ErrorContainer, Authorization
* and also sets the request parameters, files parameters, the format of the output
* and of course the most important part which is the action/output contexts themselves.
*
* @warning IF-Clusterfuck.
*
* @see Security
* @see ErrorContainer
* @see Authorization
* @see Frapi_Router
*/
public function __construct()
{
try {
$this->security = new Frapi_Security();
$this->authorization = new Frapi_Authorization();
$this->router = new Frapi_Router();
$this->router->loadAndPrepareRoutes();
$this->setInputFormat();
$uri = $_SERVER['REQUEST_URI'];
// For some reason, this is now a fatal
// error in 5.3 and no longer a warning
// in php (parse_url() with an http:// in the URL_PATH)...
if (stristr($uri, '?') !== false) {
$uri = substr($uri, 0, strpos($uri, '?'));
}
$query_path = parse_url($uri, PHP_URL_PATH);
//Query ending in .xxx may or may not be an output format
$query_path_format = null;
if (strrpos($query_path, '.')) {
$query_path_format = substr($query_path, $format_pos = strrpos($query_path, '.') + 1);
}
if (Frapi_Rules::validateOutputType($query_path_format) === true) {
//Output format suffix is valid, remove from URL!
$query_path = substr($query_path, 0, $format_pos - 1);
} else {
$query_path_format = null;
}
if ($routed = $this->router->match($query_path)) {
$_REQUEST = array_merge($_REQUEST, $routed['params']);
$this->setAction(strtolower($routed['action']));
$this->setRequest($_REQUEST);
} else {
$this->setRequest($_REQUEST);
$this->setAction($this->getParam('action'));
}
$this->setFiles($_FILES);
try {
$format = $this->getParam('format');
if (!is_null($query_path_format)) {
$format = $query_path_format;
$this->formatSetByExtension = true;
}
$setFormat = $this->getFormat();
$this->setFormat(isset($setFormat) && Frapi_Controller_Api::DEFAULT_OUTPUT_FORMAT == $setFormat ? $format : $setFormat);
} catch (Frapi_Exception $fex) {
$this->setFormat($this->getDefaultFormatFromConfiguration());
}
$this->authorization->setAuthorizationParams($this->getParams());
} catch (Frapi_Exception $e) {
// Something RONG happened. Need to tell developers.
throw $e;
} catch (Exception $e) {
// Something else? Silence! I Keeel you.
}
}
示例3: __construct
/**
* Constructor
*
* Upon invoking of the constructor, a few objects need to be created
* in order to approve, authorize and secure the action contexts.
*
* This constructor sets up the Security, ErrorContainer, Authorization
* and also sets the request parameters, files parameters, the format of the output
* and of course the most important part which is the action/output contexts themselves.
*
* @warning IF-Clusterfuck.
*
* @see Security
* @see ErrorContainer
* @see Authorization
* @see Frapi_Router
*/
public function __construct()
{
try {
$this->security = new Frapi_Security();
$this->authorization = new Frapi_Authorization();
$this->router = new Frapi_Router();
$this->router->loadAndPrepareRoutes();
$query_path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
//Query ending in .xxx may or may not be an output format
$query_path_format = null;
if (strrpos($query_path, '.')) {
$query_path_format = substr($query_path, $format_pos = strrpos($query_path, '.') + 1);
}
if (Frapi_Rules::validateOutputType($query_path_format) === true) {
//Output format suffix is valid, remove from URL!
$query_path = substr($query_path, 0, $format_pos - 1);
} else {
$query_path_format = null;
}
if ($routed = $this->router->match($query_path)) {
$_REQUEST = array_merge($_REQUEST, $routed['params']);
$this->setAction(strtolower($routed['action']));
$this->setRequest($_REQUEST);
} else {
$this->setRequest($_REQUEST);
$this->setAction($this->getParam('action'));
}
$this->setFiles($_FILES);
try {
if (!is_null($query_path_format)) {
$format = $query_path_format;
} else {
$format = $this->getParam('format');
}
$this->setFormat($format);
} catch (Frapi_Exception $fex) {
$this->setFormat($this->getDefaultFormatFromConfiguration());
}
$this->authorization->setAuthorizationParams($this->getParams());
} catch (Exception $e) {
throw $e;
}
}