Commit c52a4061 authored by Ana Rute Mendes's avatar Ana Rute Mendes 🌈
Browse files

LOCAL: Maniphest: trigger asset item creation

When a Purchasing Request changes status to "To Relase" an asset
must be created in the inventory system, external from Phabricator.

Trigger the create asset method that is placed in the extensions folder.
parent 80df29d9
......@@ -383,11 +383,19 @@ final class ManiphestTransactionEditor
$is_open = !$object->isClosed();
$asset_id = null;
$new_status = null;
foreach ($xactions as $xaction) {
switch ($xaction->getTransactionType()) {
case ManiphestTaskStatusTransaction::TRANSACTIONTYPE:
$new_status = $xaction->getNewValue();
// CCU: create Item in the inventory system if it's a Purchase request and
// its status was changed to "to release"
if (!$this->getIsNewObject()) {
$snipe_api = new SnipeItHelper();
$asset_id = $snipe_api->createAssetItem($new_status, $object, $xactions);
......@@ -441,8 +449,8 @@ final class ManiphestTransactionEditor
foreach ($xactions as $xaction) {
switch ($xaction->getTransactionType()) {
case PhabricatorTransactions::TYPE_SUBTYPE:
$subtype = $xaction->getNewValue();
$subtype = $xaction->getNewValue();
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
switch ($xaction->getMetadataValue('customfield:key')) {
......@@ -576,6 +584,17 @@ final class ManiphestTransactionEditor
// CCU: if there were an asset created in the process, refer it in the
// purchase request.
if ($asset_id) {
$results[] = id(new ManiphestTransaction())
->setMetadataValue('customfield:key', 'std:maniphest:purchasing:asset-id')
return $results;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment