Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92675145
PhabricatorFavoritesApplication.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:10
Size
2 KB
Mime Type
text/x-php
Expires
Sun, Nov 24, 16:10 (2 d)
Engine
blob
Format
Raw Data
Handle
22484412
Attached To
rPH Phabricator
PhabricatorFavoritesApplication.php
View Options
<?php
final
class
PhabricatorFavoritesApplication
extends
PhabricatorApplication
{
public
function
getBaseURI
()
{
return
'/favorites/'
;
}
public
function
getName
()
{
return
pht
(
'Favorites'
);
}
public
function
getShortDescription
()
{
return
pht
(
'Favorite Items'
);
}
public
function
getIcon
()
{
return
'fa-star'
;
}
public
function
getRoutes
()
{
return
array
(
'/favorites/'
=>
array
(
''
=>
'PhabricatorFavoritesMainController'
,
'(?P<type>global|personal)/item/'
=>
$this
->
getProfileMenuRouting
(
'PhabricatorFavoritesMenuItemController'
),
),
);
}
public
function
isLaunchable
()
{
return
false
;
}
public
function
buildMainMenuExtraNodes
(
PhabricatorUser
$viewer
,
PhabricatorController
$controller
=
null
)
{
return
id
(
new
PHUIButtonView
())
->
setTag
(
'a'
)
->
setHref
(
'#'
)
->
setIcon
(
'fa-star'
)
->
addClass
(
'phabricator-core-user-menu'
)
->
setNoCSS
(
true
)
->
setDropdown
(
true
)
->
setDropdownMenu
(
$this
->
renderFavoritesDropdown
(
$viewer
));
}
private
function
renderFavoritesDropdown
(
PhabricatorUser
$viewer
)
{
$application
=
__CLASS__
;
$favorites
=
id
(
new
PhabricatorApplicationQuery
())
->
setViewer
(
$viewer
)
->
withClasses
(
array
(
$application
))
->
withInstalled
(
true
)
->
executeOne
();
$menu_engine
=
id
(
new
PhabricatorFavoritesProfileMenuEngine
())
->
setViewer
(
$viewer
)
->
setProfileObject
(
$favorites
);
if
(
$viewer
->
getPHID
())
{
$menu_engine
->
setCustomPHID
(
$viewer
->
getPHID
())
->
setMenuType
(
PhabricatorProfileMenuEngine
::
MENU_COMBINED
);
}
else
{
$menu_engine
->
setMenuType
(
PhabricatorProfileMenuEngine
::
MENU_GLOBAL
);
}
$filter_view
=
$menu_engine
->
buildNavigation
();
$menu_view
=
$filter_view
->
getMenu
();
$item_views
=
$menu_view
->
getItems
();
$view
=
id
(
new
PhabricatorActionListView
())
->
setViewer
(
$viewer
);
foreach
(
$item_views
as
$item
)
{
$type
=
null
;
if
(!
strlen
(
$item
->
getName
()))
{
$type
=
PhabricatorActionView
::
TYPE_DIVIDER
;
}
$action
=
id
(
new
PhabricatorActionView
())
->
setName
(
$item
->
getName
())
->
setHref
(
$item
->
getHref
())
->
setType
(
$type
);
$view
->
addAction
(
$action
);
}
// Build out edit interface
if
(
$viewer
->
isLoggedIn
())
{
$view
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setType
(
PhabricatorActionView
::
TYPE_DIVIDER
));
$view
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setName
(
pht
(
'Edit Favorites'
))
->
setHref
(
'/favorites/'
));
}
return
$view
;
}
}
Event Timeline
Log In to Comment