Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92675221
PhabricatorLabelProfileMenuItem.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
Fri, Nov 22, 16:11
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Nov 24, 16:11 (2 d)
Engine
blob
Format
Raw Data
Handle
22484445
Attached To
rPH Phabricator
PhabricatorLabelProfileMenuItem.php
View Options
<?php
final
class
PhabricatorLabelProfileMenuItem
extends
PhabricatorProfileMenuItem
{
const
MENUITEMKEY
=
'label'
;
const
FIELD_NAME
=
'name'
;
public
function
getMenuItemTypeIcon
()
{
return
'fa-map-signs'
;
}
public
function
getMenuItemTypeName
()
{
return
pht
(
'Label'
);
}
public
function
canAddToObject
(
$object
)
{
return
true
;
}
public
function
getDisplayName
(
PhabricatorProfileMenuItemConfiguration
$config
)
{
return
$this
->
getLabelName
(
$config
);
}
public
function
buildEditEngineFields
(
PhabricatorProfileMenuItemConfiguration
$config
)
{
return
array
(
id
(
new
PhabricatorTextEditField
())
->
setKey
(
self
::
FIELD_NAME
)
->
setLabel
(
pht
(
'Name'
))
->
setIsRequired
(
true
)
->
setValue
(
$this
->
getLabelName
(
$config
)),
);
}
private
function
getLabelName
(
PhabricatorProfileMenuItemConfiguration
$config
)
{
return
$config
->
getMenuItemProperty
(
'name'
);
}
protected
function
newNavigationMenuItems
(
PhabricatorProfileMenuItemConfiguration
$config
)
{
$name
=
$this
->
getLabelName
(
$config
);
$item
=
$this
->
newItem
()
->
setName
(
$name
)
->
setType
(
PHUIListItemView
::
TYPE_LABEL
);
return
array
(
$item
,
);
}
public
function
validateTransactions
(
PhabricatorProfileMenuItemConfiguration
$config
,
$field_key
,
$value
,
array
$xactions
)
{
$viewer
=
$this
->
getViewer
();
$errors
=
array
();
if
(
$field_key
==
self
::
FIELD_NAME
)
{
if
(
$this
->
isEmptyTransaction
(
$value
,
$xactions
))
{
$errors
[]
=
$this
->
newRequiredError
(
pht
(
'You must choose a label name.'
),
$field_key
);
}
}
return
$errors
;
}
}
Event Timeline
Log In to Comment