Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96618680
PhabricatorRepositoryBlueprintsTransaction.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, Dec 29, 00:44
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Dec 31, 00:44 (1 d, 6 h)
Engine
blob
Format
Raw Data
Handle
23200707
Attached To
rPH Phabricator
PhabricatorRepositoryBlueprintsTransaction.php
View Options
<?php
final
class
PhabricatorRepositoryBlueprintsTransaction
extends
PhabricatorRepositoryTransactionType
{
const
TRANSACTIONTYPE
=
'repo:automation-blueprints'
;
public
function
generateOldValue
(
$object
)
{
return
$object
->
getDetail
(
'automation.blueprintPHIDs'
,
array
());
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$object
->
setDetail
(
'automation.blueprintPHIDs'
,
$value
);
}
public
function
applyExternalEffects
(
$object
,
$value
)
{
DrydockAuthorization
::
applyAuthorizationChanges
(
$this
->
getActor
(),
$object
->
getPHID
(),
$this
->
getOldValue
(),
$this
->
getNewValue
());
}
public
function
getTitle
()
{
$old
=
$this
->
getOldValue
();
$new
=
$this
->
getNewValue
();
$add
=
array_diff
(
$new
,
$old
);
$rem
=
array_diff
(
$old
,
$new
);
if
(
$add
&&
$rem
)
{
return
pht
(
'%s changed %s automation blueprint(s), '
.
'added %s: %s; removed %s: %s.'
,
$this
->
renderAuthor
(),
new
PhutilNumber
(
count
(
$add
)
+
count
(
$rem
)),
new
PhutilNumber
(
count
(
$add
)),
$this
->
renderHandleList
(
$add
),
new
PhutilNumber
(
count
(
$rem
)),
$this
->
renderHandleList
(
$rem
));
}
else
if
(
$add
)
{
return
pht
(
'%s added %s automation blueprint(s): %s.'
,
$this
->
renderAuthor
(),
new
PhutilNumber
(
count
(
$add
)),
$this
->
renderHandleList
(
$add
));
}
else
{
return
pht
(
'%s removed %s automation blueprint(s): %s.'
,
$this
->
renderAuthor
(),
new
PhutilNumber
(
count
(
$rem
)),
$this
->
renderHandleList
(
$rem
));
}
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
();
foreach
(
$xactions
as
$xaction
)
{
$old
=
nonempty
(
$xaction
->
getOldValue
(),
array
());
$new
=
nonempty
(
$xaction
->
getNewValue
(),
array
());
$add
=
array_diff
(
$new
,
$old
);
$invalid
=
PhabricatorObjectQuery
::
loadInvalidPHIDsForViewer
(
$this
->
getActor
(),
$add
);
if
(
$invalid
)
{
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'Some of the selected automation blueprints are invalid '
.
'or restricted: %s.'
,
implode
(
', '
,
$invalid
)),
$xaction
);
}
}
return
$errors
;
}
}
Event Timeline
Log In to Comment