Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7455596
FauxGlobalHookArray.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
FauxGlobalHookArray.php
View Options
<?php
namespace
MediaWiki\HookContainer
;
use
InvalidArgumentException
;
/**
* @internal
*/
class
FauxGlobalHookArray
implements
\ArrayAccess
{
private
HookContainer
$hookContainer
;
/**
* The original handler array.
* @var array
*/
private
array
$originalArray
;
/**
* @param HookContainer $hookContainer
* @param array $originalArray
*/
public
function
__construct
(
HookContainer
$hookContainer
,
array
$originalArray
=
[]
)
{
$this
->
hookContainer
=
$hookContainer
;
$this
->
originalArray
=
$originalArray
;
}
/**
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public
function
offsetExists
(
$key
)
{
wfDeprecatedMsg
(
'Accessing $wgHooks directly is deprecated, use HookContainer::isRegistered() instead.'
,
'1.40'
);
return
$this
->
hookContainer
->
isRegistered
(
$key
);
}
/**
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public
function
offsetGet
(
$key
)
{
wfDeprecatedMsg
(
'Accessing $wgHooks directly is deprecated, use HookContainer::getHandlers() '
.
'or HookContainer::register() instead.'
,
'1.40'
);
return
new
FauxHookHandlerArray
(
$this
->
hookContainer
,
$key
);
}
/**
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public
function
offsetSet
(
$key
,
$value
)
{
if
(
!
is_string
(
$key
)
)
{
throw
new
InvalidArgumentException
(
'$key must be a string'
);
}
if
(
!
is_array
(
$value
)
)
{
throw
new
InvalidArgumentException
(
'$value must be an array'
);
}
wfDeprecatedMsg
(
'Manipulating $wgHooks is deprecated, use HookContainer::clear() and '
.
'HookContainer::register() instead.'
,
'1.40'
);
$this
->
hookContainer
->
clear
(
$key
);
foreach
(
$value
as
$handler
)
{
$this
->
hookContainer
->
register
(
$key
,
$handler
);
}
}
/**
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public
function
offsetUnset
(
$key
)
{
wfDeprecatedMsg
(
'Manipulating $wgHooks is deprecated, use HookContainer::clear() instead.'
,
'1.40'
);
if
(
$this
->
hookContainer
->
isRegistered
(
$key
)
)
{
$this
->
hookContainer
->
clear
(
$key
);
}
}
public
function
getOriginalArray
():
array
{
return
$this
->
originalArray
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Nov 23, 00:05 (2 d, 16 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
16/86/156db1a05b7cdc8447bd67aca7df
Default Alt Text
FauxGlobalHookArray.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment