-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'refs/pull/487/head' of github.com:alchemy-fr/phraseanet…
…-services into w2445
- Loading branch information
Showing
6 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Listener; | ||
|
||
use Alchemy\CoreBundle\Pusher\PusherManager; | ||
use Alchemy\Workflow\Listener\WorkflowUpdateEvent; | ||
use Alchemy\Workflow\State\WorkflowState; | ||
use Symfony\Component\EventDispatcher\Attribute\AsEventListener; | ||
|
||
#[AsEventListener(event: WorkflowUpdateEvent::class, method: 'onWorkflowUpdate')] | ||
final readonly class AssetIngestWorkflowListener | ||
{ | ||
public function __construct( | ||
private PusherManager $pusherManager, | ||
) | ||
{ | ||
} | ||
|
||
public function onWorkflowUpdate(WorkflowUpdateEvent $event): void | ||
{ | ||
$state = $event->getState(); | ||
if (str_starts_with($state->getWorkflowName(), 'asset-ingest:') && in_array($state->getStatus(), [ | ||
WorkflowState::STATUS_SUCCESS, | ||
WorkflowState::STATUS_FAILURE, | ||
])) { | ||
$assetId = $state->getEvent()->getInputs()['assetId']; | ||
$this->pusherManager->trigger('asset-'.$assetId, 'asset_ingested', [], direct: true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Alchemy\Workflow\Listener; | ||
|
||
use Alchemy\Workflow\State\WorkflowState; | ||
|
||
readonly class WorkflowUpdateEvent | ||
{ | ||
public function __construct( | ||
private WorkflowState $state, | ||
) { | ||
} | ||
|
||
public function getState(): WorkflowState | ||
{ | ||
return $this->state; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters