Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90881750
DiffusionCommitEditEngine.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
Tue, Nov 5, 15:26
Size
4 KB
Mime Type
text/x-php
Expires
Thu, Nov 7, 15:26 (2 d)
Engine
blob
Format
Raw Data
Handle
22150499
Attached To
rPH Phabricator
DiffusionCommitEditEngine.php
View Options
<?php
final
class
DiffusionCommitEditEngine
extends
PhabricatorEditEngine
{
const
ENGINECONST
=
'diffusion.commit'
;
const
ACTIONGROUP_AUDIT
=
'audit'
;
const
ACTIONGROUP_COMMIT
=
'commit'
;
public
function
isEngineConfigurable
()
{
return
false
;
}
public
function
getEngineName
()
{
return
pht
(
'Commits'
);
}
public
function
getSummaryHeader
()
{
return
pht
(
'Edit Commits'
);
}
public
function
getSummaryText
()
{
return
pht
(
'Edit commits.'
);
}
public
function
getEngineApplicationClass
()
{
return
'PhabricatorDiffusionApplication'
;
}
protected
function
newEditableObject
()
{
// NOTE: We must return a valid object here so that things like Conduit
// documentation generation work. You can't actually create commits via
// EditEngine. This is enforced with a "No One" creation policy.
$repository
=
new
PhabricatorRepository
();
$data
=
new
PhabricatorRepositoryCommitData
();
return
id
(
new
PhabricatorRepositoryCommit
())
->
attachRepository
(
$repository
)
->
attachCommitData
(
$data
)
->
attachAudits
(
array
());
}
protected
function
newObjectQuery
()
{
return
id
(
new
DiffusionCommitQuery
())
->
needCommitData
(
true
)
->
needAuditRequests
(
true
);
}
protected
function
getObjectCreateTitleText
(
$object
)
{
return
pht
(
'Create Commit'
);
}
protected
function
getObjectCreateShortText
()
{
return
pht
(
'Create Commit'
);
}
protected
function
getObjectEditTitleText
(
$object
)
{
return
pht
(
'Edit Commit: %s'
,
$object
->
getDisplayName
());
}
protected
function
getObjectEditShortText
(
$object
)
{
return
$object
->
getDisplayName
();
}
protected
function
getObjectName
()
{
return
pht
(
'Commit'
);
}
protected
function
getObjectViewURI
(
$object
)
{
return
$object
->
getURI
();
}
protected
function
getCreateNewObjectPolicy
()
{
return
PhabricatorPolicies
::
POLICY_NOONE
;
}
protected
function
buildCustomEditFields
(
$object
)
{
$viewer
=
$this
->
getViewer
();
$data
=
$object
->
getCommitData
();
$fields
=
array
();
$fields
[]
=
id
(
new
PhabricatorDatasourceEditField
())
->
setKey
(
'auditors'
)
->
setLabel
(
pht
(
'Auditors'
))
->
setDatasource
(
new
DiffusionAuditorDatasource
())
->
setUseEdgeTransactions
(
true
)
->
setTransactionType
(
DiffusionCommitAuditorsTransaction
::
TRANSACTIONTYPE
)
->
setCommentActionLabel
(
pht
(
'Change Auditors'
))
->
setDescription
(
pht
(
'Auditors for this commit.'
))
->
setConduitDescription
(
pht
(
'Change the auditors for this commit.'
))
->
setConduitTypeDescription
(
pht
(
'New auditors.'
))
->
setValue
(
$object
->
getAuditorPHIDsForEdit
());
$reason
=
$data
->
getCommitDetail
(
'autocloseReason'
,
false
);
$reason
=
PhabricatorRepository
::
BECAUSE_AUTOCLOSE_FORCED
;
if
(
$reason
!==
false
)
{
switch
(
$reason
)
{
case
PhabricatorRepository
::
BECAUSE_REPOSITORY_IMPORTING
:
$desc
=
pht
(
'No, Repository Importing'
);
break
;
case
PhabricatorRepository
::
BECAUSE_AUTOCLOSE_DISABLED
:
$desc
=
pht
(
'No, Autoclose Disabled'
);
break
;
case
PhabricatorRepository
::
BECAUSE_NOT_ON_AUTOCLOSE_BRANCH
:
$desc
=
pht
(
'No, Not On Autoclose Branch'
);
break
;
case
PhabricatorRepository
::
BECAUSE_AUTOCLOSE_FORCED
:
$desc
=
pht
(
'Yes, Forced Via bin/repository CLI Tool.'
);
break
;
case
null
:
$desc
=
pht
(
'Yes'
);
break
;
default
:
$desc
=
pht
(
'Unknown'
);
break
;
}
$doc_href
=
PhabricatorEnv
::
getDoclink
(
'Diffusion User Guide: Autoclose'
);
$doc_link
=
phutil_tag
(
'a'
,
array
(
'href'
=>
$doc_href
,
'target'
=>
'_blank'
,
),
pht
(
'Learn More'
));
$fields
[]
=
id
(
new
PhabricatorStaticEditField
())
->
setLabel
(
pht
(
'Autoclose?'
))
->
setValue
(
array
(
$desc
,
"
\x
C2
\x
B7 "
,
$doc_link
));
}
$actions
=
DiffusionCommitActionTransaction
::
loadAllActions
();
$actions
=
msortv
(
$actions
,
'getCommitActionOrderVector'
);
foreach
(
$actions
as
$key
=>
$action
)
{
$fields
[]
=
$action
->
newEditField
(
$object
,
$viewer
);
}
return
$fields
;
}
}
Event Timeline
Log In to Comment