本文整理匯總了PHP中SkinTemplate::setContext方法的典型用法代碼示例。如果您正苦於以下問題:PHP SkinTemplate::setContext方法的具體用法?PHP SkinTemplate::setContext怎麽用?PHP SkinTemplate::setContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SkinTemplate
的用法示例。
在下文中一共展示了SkinTemplate::setContext方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getContextSetup
/**
* Creates a new set of object for the actual test context, including a new
* outputpage and skintemplate.
*
* @param string $mode The mode for the test cases (desktop, mobile)
* @return array Array of objects, including MobileContext (context),
* SkinTemplate (sk) and OutputPage (out)
*/
protected function getContextSetup($mode, $mfXAnalyticsItems)
{
// Create a new MobileContext object for this test
MobileContext::setInstance(null);
// create a new instance of MobileContext
$context = MobileContext::singleton();
// create a DerivativeContext to use in MobileContext later
$mainContext = new DerivativeContext(RequestContext::getMain());
// create a new, empty OutputPage
$out = new OutputPage($context);
// create a new, empty SkinTemplate
$sk = new SkinTemplate();
// create a new Title (main page)
$title = Title::newMainPage();
// create a FauxRequest to use instead of a WebRequest object (FauxRequest forces
// the creation of a FauxResponse, which allows to investigate sent header values)
$request = new FauxRequest();
// set the new request object to the context
$mainContext->setRequest($request);
// set the main page title to the context
$mainContext->setTitle($title);
// set the context to the SkinTemplate
$sk->setContext($mainContext);
// set the OutputPage to the context
$mainContext->setOutput($out);
// set the DerivativeContext as a base to MobileContext
$context->setContext($mainContext);
// set the mode to MobileContext
$context->setUseFormat($mode);
// if there are any XAnalytics items, add them
foreach ($mfXAnalyticsItems as $key => $val) {
$context->addAnalyticsLogItem($key, $val);
}
// set the newly created MobileContext object as the current instance to use
MobileContext::setInstance($context);
// return the stuff
return array('out' => $out, 'sk' => $sk, 'context' => $context);
}