Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F5313198
CopyPHIDAction.php
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
avivey
Dec 7 2017, 12:47 PM
2017-12-07 12:47:55 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
CopyPHIDAction.php
View Options
<?php
/**
* Dump this in /src/extensions, and get a "Copy PHID to clipboard" action on every page.
*/
final
class
CopyPHIDAction
extends
PhabricatorAutoEventListener
{
public
function
register
()
{
$this
->
listen
(
PhabricatorEventType
::
TYPE_UI_DIDRENDERACTIONS
);
}
public
function
handleEvent
(
PhutilEvent
$event
)
{
switch
(
$event
->
getType
())
{
case
PhabricatorEventType
::
TYPE_UI_DIDRENDERACTIONS
:
$this
->
handleActionEvent
(
$event
);
break
;
}
}
private
function
handleActionEvent
(
$event
)
{
$viewer
=
$event
->
getUser
();
$object
=
$event
->
getValue
(
'object'
);
if
(!
$object
||
!
$object
->
getPHID
())
{
return
;
}
Javelin
::
initBehavior
(
'phabricator-clipboard-copy'
);
$actions
=
$event
->
getValue
(
'actions'
);
$actions
[]
=
id
(
new
PhabricatorActionView
())
->
setHref
(
'#'
)
->
setRenderAsForm
(
true
)
->
setName
(
pht
(
'Copy PHID (%s)'
,
phid_get_type
(
$object
->
getPHID
())))
->
setIcon
(
'fa-clipboard'
)
->
addSigil
(
'clipboard-copy'
)
->
setMetadata
(
array
(
'text'
=>
$object
->
getPHID
()));
$event
->
setValue
(
'actions'
,
$actions
);
}
}
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
864249
Default Alt Text
CopyPHIDAction.php (1 KB)
Attached To
Mode
P2080 CopyPHIDAction.php
Attached
Detach File
Event Timeline
Log In to Comment