Skip to content

Commit

Permalink
Add workflow termination feature
Browse files Browse the repository at this point in the history
Implemented the ability to stop an active workflow in the Workflow service, returning the result in a new WorkflowTerminationResult class. Also updated the WorkflowActivityDocumentType class to replace targetDocumentType with targetDocumentId.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
  • Loading branch information
mesilov committed May 1, 2024
1 parent 67f0abe commit c90817a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
public function __construct(
public string $moduleId,
public string $entityId,
public string $targetDocumentType,
public string $targetDocumentId,
)
{
}

public function toArray(): array
{
return [$this->moduleId, $this->entityId, $this->targetDocumentType];
return [$this->moduleId, $this->entityId, $this->targetDocumentId];
}

public static function buildForLead(): self
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace Bitrix24\SDK\Services\Workflows\Workflow\Result;

use Bitrix24\SDK\Core\Result\AbstractResult;

class WorkflowTerminationResult extends AbstractResult
{
public function isSuccess(): bool
{
return $this->getCoreResponse()->getResponseData()->getResult()[0];
}
}
16 changes: 16 additions & 0 deletions src/Services/Workflows/Workflow/Service/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ public function __construct(
$this->batch = $batch;
}

/**
* Stops an active workflow.
*
* @param string $workflowId
* @param string $message
* @return Workflows\Workflow\Result\WorkflowTerminationResult
* @see https://training.bitrix24.com/rest_help/workflows/workflow/bizproc_workflow_terminate.php
*/
public function terminate(string $workflowId, string $message)
{
return new Workflows\Workflow\Result\WorkflowTerminationResult($this->core->call('bizproc.workflow.terminate', [
'ID' => $workflowId,
'STATUE' => $message
]));
}

/**
* bizproc.workflow.start launches a worfklow
*
Expand Down

0 comments on commit c90817a

Please sign in to comment.