Files
Phraseanet/lib/Alchemy/Phrasea/WorkerManager/Subscriber/ExposeSubscriber.php
Aina Sitraka 529a95ecfa PHRAS-3921 prod - expose-cli - became compatible with Phrasea V3 keycloak and fix (#4384)
* expose cli phrasea v3

* retrocompatible with v2

* fix connection by idp

* remove placeholder

* some fix

* some fix

* fix

* fix auth from IDP

* list expose

---------

Co-authored-by: Nicolas Maillat <maillat@alchemy.fr>
2023-10-10 22:22:23 +02:00

50 lines
1.6 KiB
PHP

<?php
namespace Alchemy\Phrasea\WorkerManager\Subscriber;
use Alchemy\Phrasea\WorkerManager\Event\ExposeUploadEvent;
use Alchemy\Phrasea\WorkerManager\Event\WorkerEvents;
use Alchemy\Phrasea\WorkerManager\Queue\MessagePublisher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ExposeSubscriber implements EventSubscriberInterface
{
/** @var MessagePublisher $messagePublisher */
private $messagePublisher;
public function __construct(MessagePublisher $messagePublisher)
{
$this->messagePublisher = $messagePublisher;
}
public function onExposeUploadAssets(ExposeUploadEvent $event)
{
foreach (explode(";", $event->getLst()) as $bas_rec) {
$basrec = explode('_', $bas_rec);
if (count($basrec) != 2) {
continue;
}
$payload = [
'message_type' => MessagePublisher::EXPOSE_UPLOAD_TYPE,
'payload' => [
'recordId' => (int) $basrec[1],
'databoxId' => (int) $basrec[0],
'exposeName' => $event->getExposeName(),
'publicationId' => $event->getPublicationId(),
'accessTokenInfo' => $event->getAccessTokenInfo()
]
];
$this->messagePublisher->publishMessage($payload, MessagePublisher::EXPOSE_UPLOAD_TYPE);
}
}
public static function getSubscribedEvents()
{
return [
WorkerEvents::EXPOSE_UPLOAD_ASSETS => 'onExposeUploadAssets',
];
}
}