本文整理汇总了PHP中ParserOptions::newFromAnon方法的典型用法代码示例。如果您正苦于以下问题:PHP ParserOptions::newFromAnon方法的具体用法?PHP ParserOptions::newFromAnon怎么用?PHP ParserOptions::newFromAnon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParserOptions
的用法示例。
在下文中一共展示了ParserOptions::newFromAnon方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parserOptions
/**
* Get/set the ParserOptions object to use for wikitext parsing
*
* @param ParserOptions|null $options Either the ParserOption to use or null to only get the
* current ParserOption object
* @return ParserOptions
*/
public function parserOptions($options = null)
{
if ($options !== null && !empty($options->isBogus)) {
// Someone is trying to set a bogus pre-$wgUser PO. Check if it has
// been changed somehow, and keep it if so.
$anonPO = ParserOptions::newFromAnon();
$anonPO->setEditSection(false);
if (!$options->matches($anonPO)) {
wfLogWarning(__METHOD__ . ': Setting a changed bogus ParserOptions: ' . wfGetAllCallers(5));
$options->isBogus = false;
}
}
if (!$this->mParserOptions) {
if (!$this->getContext()->getUser()->isSafeToLoad()) {
// $wgUser isn't unstubbable yet, so don't try to get a
// ParserOptions for it. And don't cache this ParserOptions
// either.
$po = ParserOptions::newFromAnon();
$po->setEditSection(false);
$po->isBogus = true;
if ($options !== null) {
$this->mParserOptions = empty($options->isBogus) ? $options : null;
}
return $po;
}
$this->mParserOptions = ParserOptions::newFromContext($this->getContext());
$this->mParserOptions->setEditSection(false);
}
if ($options !== null && !empty($options->isBogus)) {
// They're trying to restore the bogus pre-$wgUser PO. Do the right
// thing.
return wfSetVar($this->mParserOptions, null, true);
} else {
return wfSetVar($this->mParserOptions, $options);
}
}
示例2: getParserOptions
/**
* ParserOptions is lazy initialised.
*
* @return ParserOptions
*/
function getParserOptions()
{
global $wgUser;
if (!$this->mParserOptions) {
if (!$wgUser->isSafeToLoad()) {
// $wgUser isn't unstubbable yet, so don't try to get a
// ParserOptions for it. And don't cache this ParserOptions
// either.
$po = ParserOptions::newFromAnon();
$po->setEditSection(false);
return $po;
}
$this->mParserOptions = new ParserOptions();
$this->mParserOptions->setEditSection(false);
}
return $this->mParserOptions;
}