Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1432611
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
Sat, May 16, 22:04 (1 d, 5 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
99/4f/24931b7a0a250ede6d5e55b5f00f
Default Alt Text
FauxGlobalHookArray.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment