Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5986254
Bundler.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
Bundler.php
View Options
<?php
namespace
MediaWiki\Extension\Notifications
;
class
Bundler
{
private
function
sort
(
&
$array
)
{
usort
(
$array
,
static
function
(
Bundleable
$a
,
Bundleable
$b
)
{
return
strcmp
(
$b
->
getSortingKey
(),
$a
->
getSortingKey
()
);
}
);
}
/**
* Bundle bundleable elements that can be bundled by their bundling keys
*
* @param Bundleable[] $bundleables
* @return Bundleable[] Grouped notifications sorted by timestamp DESC
*/
public
function
bundle
(
array
$bundleables
)
{
$groups
=
[];
$bundled
=
[];
/** @var Bundleable $element */
foreach
(
$bundleables
as
$element
)
{
if
(
$element
->
canBeBundled
()
&&
$element
->
getBundlingKey
()
)
{
$groups
[
$element
->
getBundlingKey
()
][]
=
$element
;
}
else
{
$bundled
[]
=
$element
;
}
}
foreach
(
$groups
as
$bundlingKey
=>
$group
)
{
$this
->
sort
(
$group
);
/** @var Bundleable $base */
$base
=
array_shift
(
$group
);
$base
->
setBundledElements
(
$group
);
$bundled
[]
=
$base
;
}
$this
->
sort
(
$bundled
);
return
$bundled
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Oct 4, 00:02 (2 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
cd/8b/35b1106d5aecf5219ee24f69e232
Default Alt Text
Bundler.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment