本文整理汇总了PHP中RequestHandler::setContext方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestHandler::setContext方法的具体用法?PHP RequestHandler::setContext怎么用?PHP RequestHandler::setContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestHandler
的用法示例。
在下文中一共展示了RequestHandler::setContext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: factory
/**
* @param DomDocument $context
* @param \BaseXMS\Mvc\SiteAccess $siteAccess
* @return Ambigous <NULL, unknown, \BaseXMS\RequestHandler\RequestHandler>
*/
public static function factory($context, \BaseXMS\Mvc\SiteAccess $siteAccess)
{
$return = null;
$services = $siteAccess->getServiceLocator();
// Get Request handler class
$requestHandlerClass = $context->queryToValue('//contentclass');
//TODO: contentclass is not really the right name
if (!$requestHandlerClass) {
$requestHandlerClass = '\\BaseXMS\\RequestHandler\\RequestHandler';
$services->get('log')->warn('No RequestHandler class specified - falling back to default class.');
}
if (!class_exists($requestHandlerClass)) {
$services->get('log')->warn('Could not find RequestHandler class: "' . $requestHandlerClass . '".');
$requestHandlerClass = '\\BaseXMS\\RequestHandler\\RequestHandler';
}
$services->get('log')->info('Loading RequestHandler class: "' . $requestHandlerClass . '".');
$return = new $requestHandlerClass();
// couldn't get a valid class
if (!$return instanceof RequestHandler) {
$services->get('log')->warn('"' . $requestHandlerClass . '" is not a RequestHandler - falling back to default class.');
$return = new RequestHandler();
}
$return->setContext($context)->setServiceLocator($services)->setSiteAccess($siteAccess);
return $return;
}