mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 23:43:12 +00:00
retrieve permalink if empty when sending webhook (#4251)
This commit is contained in:
@@ -34,8 +34,9 @@ class EventProcessorFactory
|
|||||||
$this->registerFactory(WebhookEvent::ORDER_TYPE, new OrderNotificationProcessorFactory($app));
|
$this->registerFactory(WebhookEvent::ORDER_TYPE, new OrderNotificationProcessorFactory($app));
|
||||||
|
|
||||||
$this->registerFactory(WebhookEvent::USER_TYPE, new UserProcessorFactory());
|
$this->registerFactory(WebhookEvent::USER_TYPE, new UserProcessorFactory());
|
||||||
$this->registerCallableFactory(WebhookEvent::RECORD_SUBDEF_TYPE, function () {
|
$this->registerCallableFactory(WebhookEvent::RECORD_SUBDEF_TYPE, function () use ($app) {
|
||||||
return new SubdefEventProcessor();
|
return (new SubdefEventProcessor())
|
||||||
|
->setApplicationBox($app['phraseanet.appbox']);
|
||||||
});
|
});
|
||||||
$this->registerCallableFactory(WebhookEvent::RECORD_TYPE, function () {
|
$this->registerCallableFactory(WebhookEvent::RECORD_TYPE, function () {
|
||||||
return new RecordEventProcessor();
|
return new RecordEventProcessor();
|
||||||
|
@@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Webhook\Processor;
|
namespace Alchemy\Phrasea\Webhook\Processor;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application\Helper\ApplicationBoxAware;
|
||||||
use Alchemy\Phrasea\Model\Entities\WebhookEvent;
|
use Alchemy\Phrasea\Model\Entities\WebhookEvent;
|
||||||
|
|
||||||
class SubdefEventProcessor implements ProcessorInterface
|
class SubdefEventProcessor implements ProcessorInterface
|
||||||
{
|
{
|
||||||
|
use ApplicationBoxAware;
|
||||||
|
|
||||||
public function process(WebhookEvent $event)
|
public function process(WebhookEvent $event)
|
||||||
{
|
{
|
||||||
@@ -18,6 +20,26 @@ class SubdefEventProcessor implements ProcessorInterface
|
|||||||
unset($data['url']);
|
unset($data['url']);
|
||||||
unset($data['instance_name']);
|
unset($data['instance_name']);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$record = $this->findDataboxById($data['databox_id'])->get_record($data['record_id']);
|
||||||
|
$subdef = $record->get_subdef($data['subdef_name']);
|
||||||
|
|
||||||
|
if (empty($data['permalink'])) {
|
||||||
|
$data['permalink'] = $subdef->get_permalink()->get_url()->__toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($data['size'])) {
|
||||||
|
$data['size'] = $subdef->get_size();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($data['type'])) {
|
||||||
|
$data['type'] = $subdef->get_mime();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// if some error, we use the initial webhook data
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'event' => $event->getName(),
|
'event' => $event->getName(),
|
||||||
'webhookId' => $event->getId(),
|
'webhookId' => $event->getId(),
|
||||||
|
Reference in New Issue
Block a user