Add new ParserOutput::{get,set}OutputFlag() interface
This is a uniform mechanism to access a number of bespoke boolean
flags in ParserOutput. It allows extensibility in core (by adding new
field names to ParserOutputFlags) without exposing new getter/setter
methods to Parsoid. It replaces the ParserOutput::{get,set}Flag()
interface which (a) doesn't allow access to certain flags, and (b) is
typically called with a string rather than a constant, and (c) has a
very generic name. (Note that Parser::setOutputFlag() already called
these "output flags".)
In the future we might unify the representation so that we store
everything in $mFlags and don't have explicit properties in
ParserOutput, but those representation details should be invisible to
the clients of this API. (We might also use a proper enumeration
for ParserOutputFlags, when PHP supports this.)
There is some overlap with ParserOutput::{get,set}ExtensionData(), but
I've left those methods as-is because (a) they allow for non-boolean
data, unlike the *Flag() methods, and (b) it seems worthwhile to
distingush properties set by extensions from properties used by core.
Code search:
https://codesearch.wmcloud.org/search/?q=%5BOo%5Dut%28put%29%3F%28%5C%28%5C%29%29%3F-%3E%28g%7Cs%29etFlag%5C%28&i=nope&files=&excludeFiles=&repos=
Bug: T292868
Change-Id: I39bc58d207836df6f328c54be9e3330719cebbeb
2021-10-08 20:04:37 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Registry of flags used with ParserOutput::setOutputFlag() within
|
|
|
|
|
* MediaWiki core.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @since 1.38
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup Parser
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace MediaWiki\Parser;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Registry of flags used with ParserOutput::{get,set}OutputFlag() within
|
|
|
|
|
* MediaWiki core.
|
|
|
|
|
*
|
|
|
|
|
* All flags used should be defined in this class.
|
|
|
|
|
*
|
|
|
|
|
* It is recommended that new flag names in core should begin with 'mw-'
|
|
|
|
|
* in order to prevent namespace conflicts with legacy flags.
|
|
|
|
|
*
|
|
|
|
|
* @package MediaWiki\Parser
|
|
|
|
|
*/
|
|
|
|
|
class ParserOutputFlags {
|
|
|
|
|
|
|
|
|
|
// These flags are currently stored as ParserOutput properties
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string No gallery on category page? (__NOGALLERY__).
|
2023-12-14 19:20:33 +00:00
|
|
|
* @see ParserOutput::getNoGallery()
|
|
|
|
|
* @see ParserOutput::setNoGallery()
|
Add new ParserOutput::{get,set}OutputFlag() interface
This is a uniform mechanism to access a number of bespoke boolean
flags in ParserOutput. It allows extensibility in core (by adding new
field names to ParserOutputFlags) without exposing new getter/setter
methods to Parsoid. It replaces the ParserOutput::{get,set}Flag()
interface which (a) doesn't allow access to certain flags, and (b) is
typically called with a string rather than a constant, and (c) has a
very generic name. (Note that Parser::setOutputFlag() already called
these "output flags".)
In the future we might unify the representation so that we store
everything in $mFlags and don't have explicit properties in
ParserOutput, but those representation details should be invisible to
the clients of this API. (We might also use a proper enumeration
for ParserOutputFlags, when PHP supports this.)
There is some overlap with ParserOutput::{get,set}ExtensionData(), but
I've left those methods as-is because (a) they allow for non-boolean
data, unlike the *Flag() methods, and (b) it seems worthwhile to
distingush properties set by extensions from properties used by core.
Code search:
https://codesearch.wmcloud.org/search/?q=%5BOo%5Dut%28put%29%3F%28%5C%28%5C%29%29%3F-%3E%28g%7Cs%29etFlag%5C%28&i=nope&files=&excludeFiles=&repos=
Bug: T292868
Change-Id: I39bc58d207836df6f328c54be9e3330719cebbeb
2021-10-08 20:04:37 +00:00
|
|
|
*/
|
|
|
|
|
public const NO_GALLERY = 'mw-NoGallery';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string Whether OOUI should be enabled.
|
2023-12-14 19:20:33 +00:00
|
|
|
* @see ParserOutput::getEnableOOUI()
|
|
|
|
|
* @see ParserOutput::setEnableOOUI()
|
Add new ParserOutput::{get,set}OutputFlag() interface
This is a uniform mechanism to access a number of bespoke boolean
flags in ParserOutput. It allows extensibility in core (by adding new
field names to ParserOutputFlags) without exposing new getter/setter
methods to Parsoid. It replaces the ParserOutput::{get,set}Flag()
interface which (a) doesn't allow access to certain flags, and (b) is
typically called with a string rather than a constant, and (c) has a
very generic name. (Note that Parser::setOutputFlag() already called
these "output flags".)
In the future we might unify the representation so that we store
everything in $mFlags and don't have explicit properties in
ParserOutput, but those representation details should be invisible to
the clients of this API. (We might also use a proper enumeration
for ParserOutputFlags, when PHP supports this.)
There is some overlap with ParserOutput::{get,set}ExtensionData(), but
I've left those methods as-is because (a) they allow for non-boolean
data, unlike the *Flag() methods, and (b) it seems worthwhile to
distingush properties set by extensions from properties used by core.
Code search:
https://codesearch.wmcloud.org/search/?q=%5BOo%5Dut%28put%29%3F%28%5C%28%5C%29%29%3F-%3E%28g%7Cs%29etFlag%5C%28&i=nope&files=&excludeFiles=&repos=
Bug: T292868
Change-Id: I39bc58d207836df6f328c54be9e3330719cebbeb
2021-10-08 20:04:37 +00:00
|
|
|
*/
|
|
|
|
|
public const ENABLE_OOUI = 'mw-EnableOOUI';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string Force index policy to be 'index'
|
2023-12-14 19:20:33 +00:00
|
|
|
* @see ParserOutput::getIndexPolicy()
|
|
|
|
|
* @see ParserOutput::setIndexPolicy()
|
Add new ParserOutput::{get,set}OutputFlag() interface
This is a uniform mechanism to access a number of bespoke boolean
flags in ParserOutput. It allows extensibility in core (by adding new
field names to ParserOutputFlags) without exposing new getter/setter
methods to Parsoid. It replaces the ParserOutput::{get,set}Flag()
interface which (a) doesn't allow access to certain flags, and (b) is
typically called with a string rather than a constant, and (c) has a
very generic name. (Note that Parser::setOutputFlag() already called
these "output flags".)
In the future we might unify the representation so that we store
everything in $mFlags and don't have explicit properties in
ParserOutput, but those representation details should be invisible to
the clients of this API. (We might also use a proper enumeration
for ParserOutputFlags, when PHP supports this.)
There is some overlap with ParserOutput::{get,set}ExtensionData(), but
I've left those methods as-is because (a) they allow for non-boolean
data, unlike the *Flag() methods, and (b) it seems worthwhile to
distingush properties set by extensions from properties used by core.
Code search:
https://codesearch.wmcloud.org/search/?q=%5BOo%5Dut%28put%29%3F%28%5C%28%5C%29%29%3F-%3E%28g%7Cs%29etFlag%5C%28&i=nope&files=&excludeFiles=&repos=
Bug: T292868
Change-Id: I39bc58d207836df6f328c54be9e3330719cebbeb
2021-10-08 20:04:37 +00:00
|
|
|
*/
|
|
|
|
|
public const INDEX_POLICY = 'mw-IndexPolicy';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string Force index policy to be 'noindex'
|
2023-12-14 19:20:33 +00:00
|
|
|
* @see ParserOutput::getIndexPolicy()
|
|
|
|
|
* @see ParserOutput::setIndexPolicy()
|
Add new ParserOutput::{get,set}OutputFlag() interface
This is a uniform mechanism to access a number of bespoke boolean
flags in ParserOutput. It allows extensibility in core (by adding new
field names to ParserOutputFlags) without exposing new getter/setter
methods to Parsoid. It replaces the ParserOutput::{get,set}Flag()
interface which (a) doesn't allow access to certain flags, and (b) is
typically called with a string rather than a constant, and (c) has a
very generic name. (Note that Parser::setOutputFlag() already called
these "output flags".)
In the future we might unify the representation so that we store
everything in $mFlags and don't have explicit properties in
ParserOutput, but those representation details should be invisible to
the clients of this API. (We might also use a proper enumeration
for ParserOutputFlags, when PHP supports this.)
There is some overlap with ParserOutput::{get,set}ExtensionData(), but
I've left those methods as-is because (a) they allow for non-boolean
data, unlike the *Flag() methods, and (b) it seems worthwhile to
distingush properties set by extensions from properties used by core.
Code search:
https://codesearch.wmcloud.org/search/?q=%5BOo%5Dut%28put%29%3F%28%5C%28%5C%29%29%3F-%3E%28g%7Cs%29etFlag%5C%28&i=nope&files=&excludeFiles=&repos=
Bug: T292868
Change-Id: I39bc58d207836df6f328c54be9e3330719cebbeb
2021-10-08 20:04:37 +00:00
|
|
|
*/
|
|
|
|
|
public const NO_INDEX_POLICY = 'mw-NoIndexPolicy';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string Show a new section link?
|
2023-12-14 19:20:33 +00:00
|
|
|
* @see ParserOutput::getNewSection()
|
|
|
|
|
* @see ParserOutput::setNewSection()
|
Add new ParserOutput::{get,set}OutputFlag() interface
This is a uniform mechanism to access a number of bespoke boolean
flags in ParserOutput. It allows extensibility in core (by adding new
field names to ParserOutputFlags) without exposing new getter/setter
methods to Parsoid. It replaces the ParserOutput::{get,set}Flag()
interface which (a) doesn't allow access to certain flags, and (b) is
typically called with a string rather than a constant, and (c) has a
very generic name. (Note that Parser::setOutputFlag() already called
these "output flags".)
In the future we might unify the representation so that we store
everything in $mFlags and don't have explicit properties in
ParserOutput, but those representation details should be invisible to
the clients of this API. (We might also use a proper enumeration
for ParserOutputFlags, when PHP supports this.)
There is some overlap with ParserOutput::{get,set}ExtensionData(), but
I've left those methods as-is because (a) they allow for non-boolean
data, unlike the *Flag() methods, and (b) it seems worthwhile to
distingush properties set by extensions from properties used by core.
Code search:
https://codesearch.wmcloud.org/search/?q=%5BOo%5Dut%28put%29%3F%28%5C%28%5C%29%29%3F-%3E%28g%7Cs%29etFlag%5C%28&i=nope&files=&excludeFiles=&repos=
Bug: T292868
Change-Id: I39bc58d207836df6f328c54be9e3330719cebbeb
2021-10-08 20:04:37 +00:00
|
|
|
*/
|
|
|
|
|
public const NEW_SECTION = 'mw-NewSection';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string Hide the new section link?
|
2023-12-14 19:20:33 +00:00
|
|
|
* @see ParserOutput::getHideNewSection()
|
|
|
|
|
* @see ParserOutput::setHideNewSection()
|
Add new ParserOutput::{get,set}OutputFlag() interface
This is a uniform mechanism to access a number of bespoke boolean
flags in ParserOutput. It allows extensibility in core (by adding new
field names to ParserOutputFlags) without exposing new getter/setter
methods to Parsoid. It replaces the ParserOutput::{get,set}Flag()
interface which (a) doesn't allow access to certain flags, and (b) is
typically called with a string rather than a constant, and (c) has a
very generic name. (Note that Parser::setOutputFlag() already called
these "output flags".)
In the future we might unify the representation so that we store
everything in $mFlags and don't have explicit properties in
ParserOutput, but those representation details should be invisible to
the clients of this API. (We might also use a proper enumeration
for ParserOutputFlags, when PHP supports this.)
There is some overlap with ParserOutput::{get,set}ExtensionData(), but
I've left those methods as-is because (a) they allow for non-boolean
data, unlike the *Flag() methods, and (b) it seems worthwhile to
distingush properties set by extensions from properties used by core.
Code search:
https://codesearch.wmcloud.org/search/?q=%5BOo%5Dut%28put%29%3F%28%5C%28%5C%29%29%3F-%3E%28g%7Cs%29etFlag%5C%28&i=nope&files=&excludeFiles=&repos=
Bug: T292868
Change-Id: I39bc58d207836df6f328c54be9e3330719cebbeb
2021-10-08 20:04:37 +00:00
|
|
|
*/
|
|
|
|
|
public const HIDE_NEW_SECTION = 'mw-HideNewSection';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string The prevent-clickjacking flag
|
2023-12-14 19:20:33 +00:00
|
|
|
* @see ParserOutput::getPreventClickjacking()
|
|
|
|
|
* @see ParserOutput::setPreventClickjacking()
|
Add new ParserOutput::{get,set}OutputFlag() interface
This is a uniform mechanism to access a number of bespoke boolean
flags in ParserOutput. It allows extensibility in core (by adding new
field names to ParserOutputFlags) without exposing new getter/setter
methods to Parsoid. It replaces the ParserOutput::{get,set}Flag()
interface which (a) doesn't allow access to certain flags, and (b) is
typically called with a string rather than a constant, and (c) has a
very generic name. (Note that Parser::setOutputFlag() already called
these "output flags".)
In the future we might unify the representation so that we store
everything in $mFlags and don't have explicit properties in
ParserOutput, but those representation details should be invisible to
the clients of this API. (We might also use a proper enumeration
for ParserOutputFlags, when PHP supports this.)
There is some overlap with ParserOutput::{get,set}ExtensionData(), but
I've left those methods as-is because (a) they allow for non-boolean
data, unlike the *Flag() methods, and (b) it seems worthwhile to
distingush properties set by extensions from properties used by core.
Code search:
https://codesearch.wmcloud.org/search/?q=%5BOo%5Dut%28put%29%3F%28%5C%28%5C%29%29%3F-%3E%28g%7Cs%29etFlag%5C%28&i=nope&files=&excludeFiles=&repos=
Bug: T292868
Change-Id: I39bc58d207836df6f328c54be9e3330719cebbeb
2021-10-08 20:04:37 +00:00
|
|
|
*/
|
|
|
|
|
public const PREVENT_CLICKJACKING = 'mw-PreventClickjacking';
|
|
|
|
|
|
|
|
|
|
// These flags are stored in the ParserOutput::$mFlags array
|
|
|
|
|
|
2022-05-27 16:20:35 +00:00
|
|
|
/**
|
2023-03-21 18:26:05 +00:00
|
|
|
* @var string Show the table of contents in the skin? This is
|
|
|
|
|
* a /suggestion/ based on whether the TOC is "large enough"
|
|
|
|
|
* and other factors, and is intended mostly for skins which
|
|
|
|
|
* want to match the behavior of the traditional inline ToC.
|
2022-05-27 16:20:35 +00:00
|
|
|
*/
|
2022-07-27 22:07:09 +00:00
|
|
|
public const SHOW_TOC = 'show-toc';
|
2022-05-27 16:20:35 +00:00
|
|
|
|
2023-03-21 18:26:05 +00:00
|
|
|
/**
|
|
|
|
|
* @var string Suppress the table of contents in the skin?
|
|
|
|
|
* This reflects the use of the __NOTOC__ magic word in the
|
|
|
|
|
* article (possibly modified by __TOC__ or __FORCETOC__),
|
|
|
|
|
* and represents an explicit request from the author to
|
|
|
|
|
* hide the TOC.
|
|
|
|
|
*/
|
|
|
|
|
public const NO_TOC = 'no-toc';
|
|
|
|
|
|
2023-11-06 20:43:31 +00:00
|
|
|
/**
|
|
|
|
|
* @var string Suppress the section edit links?
|
|
|
|
|
* This reflects the ParserOptions::getSuppressSectionEditLinks()
|
|
|
|
|
* flag and affects the default value of `enableSectionEditLinks`
|
|
|
|
|
* in ParserOutput::getText().
|
|
|
|
|
*/
|
|
|
|
|
public const NO_SECTION_EDIT_LINKS = 'no-section-edit-links';
|
|
|
|
|
|
2024-04-05 22:46:57 +00:00
|
|
|
/**
|
|
|
|
|
* @var string Wrap section contents to allow collapsing them?
|
|
|
|
|
* This reflects the ParserOptions::getCollapsibleSections()
|
|
|
|
|
* flag.
|
|
|
|
|
*/
|
|
|
|
|
public const COLLAPSIBLE_SECTIONS = 'collapsible-sections';
|
|
|
|
|
|
Add new ParserOutput::{get,set}OutputFlag() interface
This is a uniform mechanism to access a number of bespoke boolean
flags in ParserOutput. It allows extensibility in core (by adding new
field names to ParserOutputFlags) without exposing new getter/setter
methods to Parsoid. It replaces the ParserOutput::{get,set}Flag()
interface which (a) doesn't allow access to certain flags, and (b) is
typically called with a string rather than a constant, and (c) has a
very generic name. (Note that Parser::setOutputFlag() already called
these "output flags".)
In the future we might unify the representation so that we store
everything in $mFlags and don't have explicit properties in
ParserOutput, but those representation details should be invisible to
the clients of this API. (We might also use a proper enumeration
for ParserOutputFlags, when PHP supports this.)
There is some overlap with ParserOutput::{get,set}ExtensionData(), but
I've left those methods as-is because (a) they allow for non-boolean
data, unlike the *Flag() methods, and (b) it seems worthwhile to
distingush properties set by extensions from properties used by core.
Code search:
https://codesearch.wmcloud.org/search/?q=%5BOo%5Dut%28put%29%3F%28%5C%28%5C%29%29%3F-%3E%28g%7Cs%29etFlag%5C%28&i=nope&files=&excludeFiles=&repos=
Bug: T292868
Change-Id: I39bc58d207836df6f328c54be9e3330719cebbeb
2021-10-08 20:04:37 +00:00
|
|
|
/**
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
public const VARY_REVISION = 'vary-revision';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string Similar to VARY_REVISION, but used if we didn't
|
|
|
|
|
* guess the ID correctly. Informs the edit saving system that
|
|
|
|
|
* getting the canonical output after revision insertion requires
|
|
|
|
|
* a parse that used that exact revision ID.
|
|
|
|
|
*/
|
|
|
|
|
public const VARY_REVISION_ID = 'vary-revision-id';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string Similar to VARY_REVISION, but used if we didn't
|
|
|
|
|
* guess the timestamp correctly. Informs the edit saving system
|
|
|
|
|
* that getting the canonical output after revision insertion
|
|
|
|
|
* requires a parse that used an actual revision timestamp.
|
|
|
|
|
*/
|
|
|
|
|
public const VARY_REVISION_TIMESTAMP = 'vary-revision-timestamp';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string Similar to VARY_REVISION, but used if we didn't guess the
|
|
|
|
|
* content correctly.
|
|
|
|
|
*/
|
|
|
|
|
public const VARY_REVISION_SHA1 = 'vary-revision-sha1';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string Similar to VARY_REVISION
|
|
|
|
|
*/
|
|
|
|
|
public const VARY_REVISION_EXISTS = 'vary-revision-exists';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string Similar to VARY_REVISION, but used if we didn't guess the
|
|
|
|
|
* page id correctly. Informs the edit saving system that getting the
|
|
|
|
|
* canonical output after page insertion requires a parse that used that
|
|
|
|
|
* exact page id.
|
|
|
|
|
*/
|
|
|
|
|
public const VARY_PAGE_ID = 'vary-page-id';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string Similar to VARY_REVISION. Informs the edit saving
|
|
|
|
|
* system that getting the canonical output after revision
|
|
|
|
|
* insertion requires a parse that used the actual user ID.
|
|
|
|
|
*/
|
|
|
|
|
public const VARY_USER = 'vary-user';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string Used to avoid extremely stale user signature timestamps
|
|
|
|
|
* (T84843). Set if the signature wikitext contains another '~~~~' or
|
|
|
|
|
* similar (T230652).
|
|
|
|
|
*/
|
|
|
|
|
public const USER_SIGNATURE = 'user-signature';
|
2022-02-07 16:28:23 +00:00
|
|
|
|
2024-01-12 05:07:33 +00:00
|
|
|
/**
|
|
|
|
|
* @var string Set when the parse is done in "preview mode", in which
|
|
|
|
|
* case various shortcuts are taken to work around the fact that the
|
|
|
|
|
* parsed text does not yet have an actual revision ID, revision time,
|
|
|
|
|
* etc.
|
|
|
|
|
* @see ParserOptions::getIsPreview()
|
|
|
|
|
*/
|
|
|
|
|
public const IS_PREVIEW = 'is-preview';
|
|
|
|
|
|
2022-02-07 16:28:23 +00:00
|
|
|
public static function cases(): array {
|
|
|
|
|
return [
|
|
|
|
|
self::NO_GALLERY,
|
|
|
|
|
self::ENABLE_OOUI,
|
|
|
|
|
self::INDEX_POLICY,
|
|
|
|
|
self::NO_INDEX_POLICY,
|
|
|
|
|
self::NEW_SECTION,
|
|
|
|
|
self::HIDE_NEW_SECTION,
|
2022-07-27 22:07:09 +00:00
|
|
|
self::SHOW_TOC,
|
2023-03-21 18:26:05 +00:00
|
|
|
self::NO_TOC,
|
2023-11-06 20:43:31 +00:00
|
|
|
self::NO_SECTION_EDIT_LINKS,
|
2024-04-05 22:46:57 +00:00
|
|
|
self::COLLAPSIBLE_SECTIONS,
|
2022-02-07 16:28:23 +00:00
|
|
|
self::PREVENT_CLICKJACKING,
|
|
|
|
|
self::VARY_REVISION,
|
|
|
|
|
self::VARY_REVISION_ID,
|
|
|
|
|
self::VARY_REVISION_TIMESTAMP,
|
|
|
|
|
self::VARY_REVISION_SHA1,
|
|
|
|
|
self::VARY_REVISION_EXISTS,
|
|
|
|
|
self::VARY_PAGE_ID,
|
|
|
|
|
self::VARY_USER,
|
|
|
|
|
self::USER_SIGNATURE,
|
2024-01-12 05:07:33 +00:00
|
|
|
self::IS_PREVIEW,
|
2022-02-07 16:28:23 +00:00
|
|
|
];
|
|
|
|
|
}
|
Add new ParserOutput::{get,set}OutputFlag() interface
This is a uniform mechanism to access a number of bespoke boolean
flags in ParserOutput. It allows extensibility in core (by adding new
field names to ParserOutputFlags) without exposing new getter/setter
methods to Parsoid. It replaces the ParserOutput::{get,set}Flag()
interface which (a) doesn't allow access to certain flags, and (b) is
typically called with a string rather than a constant, and (c) has a
very generic name. (Note that Parser::setOutputFlag() already called
these "output flags".)
In the future we might unify the representation so that we store
everything in $mFlags and don't have explicit properties in
ParserOutput, but those representation details should be invisible to
the clients of this API. (We might also use a proper enumeration
for ParserOutputFlags, when PHP supports this.)
There is some overlap with ParserOutput::{get,set}ExtensionData(), but
I've left those methods as-is because (a) they allow for non-boolean
data, unlike the *Flag() methods, and (b) it seems worthwhile to
distingush properties set by extensions from properties used by core.
Code search:
https://codesearch.wmcloud.org/search/?q=%5BOo%5Dut%28put%29%3F%28%5C%28%5C%29%29%3F-%3E%28g%7Cs%29etFlag%5C%28&i=nope&files=&excludeFiles=&repos=
Bug: T292868
Change-Id: I39bc58d207836df6f328c54be9e3330719cebbeb
2021-10-08 20:04:37 +00:00
|
|
|
}
|