Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F105200182
DarkConsoleCore.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Mar 15, 09:40
Size
2 KB
Mime Type
text/x-php
Expires
Mon, Mar 17, 09:40 (2 d)
Engine
blob
Format
Raw Data
Handle
24942677
Attached To
rPH Phabricator
DarkConsoleCore.php
View Options
<?php
/**
* @group console
*/
final
class
DarkConsoleCore
{
private
$plugins
=
array
();
const
STORAGE_VERSION
=
1
;
public
function
__construct
()
{
$symbols
=
id
(
new
PhutilSymbolLoader
())
->
setType
(
'class'
)
->
setAncestorClass
(
'DarkConsolePlugin'
)
->
selectAndLoadSymbols
();
foreach
(
$symbols
as
$symbol
)
{
$plugin
=
newv
(
$symbol
[
'name'
],
array
());
if
(!
$plugin
->
shouldStartup
())
{
continue
;
}
$plugin
->
setConsoleCore
(
$this
);
$plugin
->
didStartup
();
$this
->
plugins
[
$symbol
[
'name'
]]
=
$plugin
;
}
}
public
function
getPlugins
()
{
return
$this
->
plugins
;
}
public
function
getKey
(
AphrontRequest
$request
)
{
$plugins
=
$this
->
getPlugins
();
foreach
(
$plugins
as
$plugin
)
{
$plugin
->
setRequest
(
$request
);
$plugin
->
willShutdown
();
}
foreach
(
$plugins
as
$plugin
)
{
$plugin
->
didShutdown
();
}
foreach
(
$plugins
as
$plugin
)
{
$plugin
->
setData
(
$plugin
->
generateData
());
}
$plugins
=
msort
(
$plugins
,
'getOrderKey'
);
$key
=
Filesystem
::
readRandomCharacters
(
24
);
$tabs
=
array
();
$data
=
array
();
foreach
(
$plugins
as
$plugin
)
{
$class
=
get_class
(
$plugin
);
$tabs
[]
=
array
(
'class'
=>
$class
,
'name'
=>
$plugin
->
getName
(),
'color'
=>
$plugin
->
getColor
(),
);
$data
[
$class
]
=
$plugin
->
getData
();
}
$storage
=
array
(
'vers'
=>
self
::
STORAGE_VERSION
,
'tabs'
=>
$tabs
,
'data'
=>
$data
,
'user'
=>
$request
->
getUser
()
?
$request
->
getUser
()->
getPHID
()
:
null
,
);
$cache
=
new
PhabricatorKeyValueDatabaseCache
();
$cache
=
new
PhutilKeyValueCacheProfiler
(
$cache
);
$cache
->
setProfiler
(
PhutilServiceProfiler
::
getInstance
());
$cache
->
setKeys
(
array
(
'darkconsole:'
.
$key
=>
json_encode
(
$storage
),
),
$ttl
=
(
60
*
60
*
6
));
return
$key
;
}
public
function
render
(
AphrontRequest
$request
)
{
$user
=
$request
->
getUser
();
$visible
=
$user
?
$user
->
getConsoleVisible
()
:
true
;
return
javelin_tag
(
'div'
,
array
(
'id'
=>
'darkconsole'
,
'class'
=>
'dark-console'
,
'style'
=>
$visible
?
''
:
'display: none;'
,
'data-console-key'
=>
$this
->
getKey
(
$request
),
),
''
);
}
}
Event Timeline
Log In to Comment