Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92872856
PhabricatorRepositoryAuthor.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
Sun, Nov 24, 09:53
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Nov 26, 09:53 (2 d)
Engine
blob
Format
Raw Data
Handle
22529996
Attached To
rPHINFRA c4science
PhabricatorRepositoryAuthor.php
View Options
<?php
final
class
PhabricatorRepositoryAuthor
extends
PhabricatorController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$data
=
$request
->
getRequestData
();
$viewer
=
$request
->
getViewer
();
$author
=
idx
(
$data
,
'authorPHID'
,
$viewer
->
getPHID
());
$author_user
=
id
(
new
PhabricatorUser
())
->
loadOneWhere
(
'phid = %s'
,
$author
);
if
(!
$author_user
)
{
return
new
Aphront404Response
();
}
$title
=
pht
(
'Repositories for %s'
,
$author_user
->
getFullName
());
// Repositories
$repo_transaction
=
id
(
new
PhabricatorRepositoryTransactionQuery
())
->
setViewer
(
$viewer
)
->
withAuthorPHIDs
(
array
(
$author
))
->
withTransactionTypes
(
array
(
PhabricatorTransactions
::
TYPE_CREATE
))
->
execute
();
if
(!
empty
(
$repo_transaction
))
{
$repo_phids
=
mpull
(
$repo_transaction
,
'getObjectPHID'
);
$repo
=
id
(
new
PhabricatorRepositoryQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
$repo_phids
)
->
withStatus
(
PhabricatorRepositoryQuery
::
STATUS_OPEN
)
->
execute
();
}
$list
=
new
PHUIObjectItemListView
();
if
(!
empty
(
$repo
))
{
foreach
(
$repo
as
$r
){
$item
=
id
(
new
PHUIObjectItemView
())
->
setUser
(
$viewer
)
->
setObject
(
$r
)
->
setHeader
(
$r
->
getName
())
->
setObjectName
(
$r
->
getMonogram
())
->
setHref
(
$r
->
getURI
());
$list
->
addItem
(
$item
);
}
}
else
{
$error
=
id
(
new
PHUIBoxView
())
->
addClass
(
'mlb'
)
->
appendChild
(
pht
(
'User does not have any repository.'
));
$list
=
id
(
new
PHUIInfoView
())
->
setSeverity
(
PHUIInfoView
::
SEVERITY_NODATA
)
->
appendChild
(
$error
);
}
// UI
$crumbs
=
$this
->
buildApplicationCrumbs
();
$crumbs
->
addCrumb
(
id
(
new
PHUICrumbView
())
->
setHref
(
'/p/'
.
$author_user
->
getUsername
())
->
setName
(
$author_user
->
getUsername
())
);
$crumbs
->
addCrumb
(
id
(
new
PHUICrumbView
())
->
setName
(
pht
(
'Repositories'
))
);
$header
=
id
(
new
PHUIHeaderView
())
->
setHeader
(
$title
)
->
setHeaderIcon
(
'fa-code'
);
$view
=
id
(
new
PHUIObjectBoxView
())
->
setHeader
(
$header
);
$view
->
setObjectList
(
$list
);
return
$this
->
newPage
()
->
setTitle
(
$title
)
->
setCrumbs
(
$crumbs
)
->
appendChild
(
$view
);
}
protected
function
buildApplicationCrumbs
()
{
$view
=
new
PHUICrumbsView
();
$view
->
addCrumb
(
id
(
new
PHUICrumbView
())
->
setHref
(
'/people/'
)
->
setName
(
pht
(
'People'
))
->
setIcon
(
'fa-users'
)
);
return
$view
;
}
}
Event Timeline
Log In to Comment