Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F445002
PhabricatorProjectProfileMenuItem.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
PhabricatorProjectProfileMenuItem.php
View Options
<?php
final
class
PhabricatorProjectProfileMenuItem
extends
PhabricatorProfileMenuItem
{
const
MENUITEMKEY
=
'project'
;
private
$project
;
public
function
getMenuItemTypeIcon
()
{
return
'fa-briefcase'
;
}
public
function
getMenuItemTypeName
()
{
return
pht
(
'Project'
);
}
public
function
canAddToObject
(
$object
)
{
return
true
;
}
public
function
attachProject
(
$project
)
{
$this
->
project
=
$project
;
return
$this
;
}
public
function
getProject
()
{
$project
=
$this
->
project
;
if
(!
$project
)
{
return
null
;
}
else
if
(
$project
->
isArchived
())
{
return
null
;
}
return
$project
;
}
public
function
willBuildNavigationItems
(
array
$items
)
{
$viewer
=
$this
->
getViewer
();
$project_phids
=
array
();
foreach
(
$items
as
$item
)
{
$project_phids
[]
=
$item
->
getMenuItemProperty
(
'project'
);
}
$projects
=
id
(
new
PhabricatorProjectQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
$project_phids
)
->
needImages
(
true
)
->
execute
();
$projects
=
mpull
(
$projects
,
null
,
'getPHID'
);
foreach
(
$items
as
$item
)
{
$project_phid
=
$item
->
getMenuItemProperty
(
'project'
);
$project
=
idx
(
$projects
,
$project_phid
,
null
);
$item
->
getMenuItem
()->
attachProject
(
$project
);
}
}
public
function
getDisplayName
(
PhabricatorProfileMenuItemConfiguration
$config
)
{
$project
=
$this
->
getProject
();
if
(!
$project
)
{
return
pht
(
'(Restricted/Invalid Project)'
);
}
if
(
strlen
(
$this
->
getName
(
$config
)))
{
return
$this
->
getName
(
$config
);
}
else
{
return
$project
->
getName
();
}
}
public
function
buildEditEngineFields
(
PhabricatorProfileMenuItemConfiguration
$config
)
{
return
array
(
id
(
new
PhabricatorTextEditField
())
->
setKey
(
'name'
)
->
setLabel
(
pht
(
'Name'
))
->
setValue
(
$this
->
getName
(
$config
)),
id
(
new
PhabricatorDatasourceEditField
())
->
setKey
(
'project'
)
->
setLabel
(
pht
(
'Project'
))
->
setDatasource
(
new
PhabricatorProjectDatasource
())
->
setSingleValue
(
$config
->
getMenuItemProperty
(
'project'
)),
);
}
private
function
getName
(
PhabricatorProfileMenuItemConfiguration
$config
)
{
return
$config
->
getMenuItemProperty
(
'name'
);
}
protected
function
newNavigationMenuItems
(
PhabricatorProfileMenuItemConfiguration
$config
)
{
$project
=
$this
->
getProject
();
if
(!
$project
)
{
return
array
();
}
$picture
=
$project
->
getProfileImageURI
();
$name
=
$this
->
getDisplayName
(
$config
);
$href
=
$project
->
getURI
();
$item
=
$this
->
newItem
()
->
setHref
(
$href
)
->
setName
(
$name
)
->
setProfileImage
(
$picture
);
return
array
(
$item
,
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, May 4, 1:00 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
65518
Default Alt Text
PhabricatorProjectProfileMenuItem.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment