diff --git a/lib/Alchemy/Phrasea/Core/Event/Record/CollectionChangedEvent.php b/lib/Alchemy/Phrasea/Core/Event/Record/CollectionChangedEvent.php index 7bdb184c0f..6ec6476feb 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Record/CollectionChangedEvent.php +++ b/lib/Alchemy/Phrasea/Core/Event/Record/CollectionChangedEvent.php @@ -13,4 +13,40 @@ namespace Alchemy\Phrasea\Core\Event\Record; class CollectionChangedEvent extends RecordEvent { + /** @var array */ + private $beforeCollection; + + /** @var array */ + private $afterCollection; + + public function __construct(\record_adapter $record, \collection $beforeCol, \collection $afterCol) + { + parent::__construct($record); + + $this->beforeCollection = [ + 'collection_name' => $beforeCol->get_name(), + 'collection_id' => $beforeCol->get_coll_id() + ]; + + $this->afterCollection = [ + 'collection_name' => $afterCol->get_name(), + 'collection_id' => $afterCol->get_coll_id() + ]; + } + + /** + * @return array + */ + public function getBeforeCollection() + { + return $this->beforeCollection; + } + + /** + * @return array + */ + public function getAfterCollection() + { + return $this->afterCollection; + } } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/WebhookRecordEventSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/WebhookRecordEventSubscriber.php index 0b866a3677..e319bdc90e 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/WebhookRecordEventSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/WebhookRecordEventSubscriber.php @@ -3,6 +3,7 @@ namespace Alchemy\Phrasea\Core\Event\Subscriber; use Alchemy\Phrasea\Application; +use Alchemy\Phrasea\Core\Event\Record\CollectionChangedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordEvent; use Alchemy\Phrasea\Core\Event\Record\RecordEvents; use Alchemy\Phrasea\Core\LazyLocator; @@ -54,9 +55,30 @@ class WebhookRecordEventSubscriber implements EventSubscriberInterface $this->createWebhookEvent($event, WebhookEvent::RECORD_MEDIA_SUBSTITUTED); } - public function onRecordCollectionChanged(RecordEvent $event) + public function onRecordCollectionChanged(CollectionChangedEvent $event) { - $this->createWebhookEvent($event, WebhookEvent::RECORD_COLLECTION_CHANGED); + $record = $this->convertToRecordAdapter($event->getRecord()); + + if ($record !== null) { + $eventData = [ + 'databox_id' => $event->getRecord()->getDataboxId(), + 'record_id' => $event->getRecord()->getRecordId(), + 'collection_name' => $record->getCollection()->get_name(), + 'record_type' => $event->getRecord()->isStory() ? "story" : "record", + 'before' => $event->getBeforeCollection(), + 'after' => $event->getAfterCollection() + ]; + + $this->app['manipulator.webhook-event']->create( + WebhookEvent::RECORD_COLLECTION_CHANGED, + WebhookEvent::RECORD_TYPE, + $eventData, + [$event->getRecord()->getBaseId()] + ); + } else { + $this->app['logger']->error("Record not found when wanting to create webhook data!"); + } + } public function onRecordStatusChanged(RecordEvent $event) diff --git a/lib/Alchemy/Phrasea/Webhook/Processor/FeedEntryProcessor.php b/lib/Alchemy/Phrasea/Webhook/Processor/FeedEntryProcessor.php index 268f1a18da..9a97d40505 100644 --- a/lib/Alchemy/Phrasea/Webhook/Processor/FeedEntryProcessor.php +++ b/lib/Alchemy/Phrasea/Webhook/Processor/FeedEntryProcessor.php @@ -75,6 +75,7 @@ class FeedEntryProcessor implements ProcessorInterface return [ 'event' => $event->getName(), + 'webhookId' => $event->getId(), 'version' => WebhookEvent::WEBHOOK_VERSION, 'url' => $data['url'], 'instance_name' => $data['instance_name'], @@ -93,8 +94,8 @@ class FeedEntryProcessor implements ProcessorInterface 'title' => $entry->getTitle(), 'description' => $entry->getSubtitle(), ], - 'users' => $users, - 'time' => $data['time'] + 'users' => $users, + 'event_time' => $data['event_time'] ]; } } diff --git a/lib/Alchemy/Phrasea/Webhook/Processor/OrderNotificationProcessor.php b/lib/Alchemy/Phrasea/Webhook/Processor/OrderNotificationProcessor.php index 8bfc484c49..c973bbfc4c 100644 --- a/lib/Alchemy/Phrasea/Webhook/Processor/OrderNotificationProcessor.php +++ b/lib/Alchemy/Phrasea/Webhook/Processor/OrderNotificationProcessor.php @@ -70,6 +70,7 @@ class OrderNotificationProcessor implements ProcessorInterface { return [ 'event' => $event->getName(), + 'webhookId' => $event->getId(), 'version' => WebhookEvent::WEBHOOK_VERSION, 'url' => $data['url'], 'instance_name' => $data['instance_name'], @@ -78,8 +79,8 @@ class OrderNotificationProcessor implements ProcessorInterface 'email' => $user->getEmail(), 'login' => $user->getLogin() ], - 'order' => $order->getId(), - 'time' => $data['time'] + 'order' => $order->getId(), + 'event_time' => $data['event_time'] ]; } } diff --git a/lib/Alchemy/Phrasea/Webhook/Processor/RecordEventProcessor.php b/lib/Alchemy/Phrasea/Webhook/Processor/RecordEventProcessor.php index f5ecb54743..a6bb154ddc 100644 --- a/lib/Alchemy/Phrasea/Webhook/Processor/RecordEventProcessor.php +++ b/lib/Alchemy/Phrasea/Webhook/Processor/RecordEventProcessor.php @@ -8,22 +8,23 @@ class RecordEventProcessor implements ProcessorInterface { public function process(WebhookEvent $event) { - $data = $event->getData(); - $time = $data['time']; - $url = $data['url']; + $data = $event->getData(); + $eventTime = $data['event_time']; + $url = $data['url']; $instanceName = $data['instance_name']; - unset($data['time']); + unset($data['event_time']); unset($data['url']); unset($data['instance_name']); return [ 'event' => $event->getName(), + 'webhookId' => $event->getId(), 'version' => WebhookEvent::WEBHOOK_VERSION, 'url' => $url, 'instance_name' => $instanceName, 'data' => $data, - 'time' => $time + 'event_time' => $eventTime ]; } } diff --git a/lib/Alchemy/Phrasea/Webhook/Processor/SubdefEventProcessor.php b/lib/Alchemy/Phrasea/Webhook/Processor/SubdefEventProcessor.php index 39a0469c41..f403a44fa2 100644 --- a/lib/Alchemy/Phrasea/Webhook/Processor/SubdefEventProcessor.php +++ b/lib/Alchemy/Phrasea/Webhook/Processor/SubdefEventProcessor.php @@ -9,22 +9,23 @@ class SubdefEventProcessor implements ProcessorInterface public function process(WebhookEvent $event) { - $data = $event->getData(); - $time = $data['time']; - $url = $data['url']; + $data = $event->getData(); + $eventTime = $data['event_time']; + $url = $data['url']; $instanceName = $data['instance_name']; - unset($data['time']); + unset($data['event_time']); unset($data['url']); unset($data['instance_name']); return [ 'event' => $event->getName(), + 'webhookId' => $event->getId(), 'version' => WebhookEvent::WEBHOOK_VERSION, 'url' => $url, 'instance_name' => $instanceName, 'data' => $data, - 'time' => $time + 'event_time' => $eventTime ]; } } diff --git a/lib/Alchemy/Phrasea/Webhook/Processor/UserProcessor.php b/lib/Alchemy/Phrasea/Webhook/Processor/UserProcessor.php index fc48c0eb5a..c6ae0dcc24 100644 --- a/lib/Alchemy/Phrasea/Webhook/Processor/UserProcessor.php +++ b/lib/Alchemy/Phrasea/Webhook/Processor/UserProcessor.php @@ -17,6 +17,7 @@ class UserProcessor implements ProcessorInterface return [ 'event' => $event->getName(), + 'webhookId' => $event->getId(), 'version' => WebhookEvent::WEBHOOK_VERSION, 'url' => $data['url'], 'instance_name' => $data['instance_name'], @@ -25,7 +26,7 @@ class UserProcessor implements ProcessorInterface 'email' => $data['email'], 'login' => $data['login'], ], - 'time' => $data['time'] + 'event_time' => $data['event_time'] ]; } } diff --git a/lib/Alchemy/Phrasea/Webhook/Processor/UserRegistrationProcessor.php b/lib/Alchemy/Phrasea/Webhook/Processor/UserRegistrationProcessor.php index f814f50acd..859e1f52c0 100644 --- a/lib/Alchemy/Phrasea/Webhook/Processor/UserRegistrationProcessor.php +++ b/lib/Alchemy/Phrasea/Webhook/Processor/UserRegistrationProcessor.php @@ -30,6 +30,7 @@ class UserRegistrationProcessor implements ProcessorInterface return [ 'event' => $event->getName(), + 'webhookId' => $event->getId(), 'version' => WebhookEvent::WEBHOOK_VERSION, 'url' => $data['url'], 'instance_name' => $data['instance_name'], @@ -40,7 +41,7 @@ class UserRegistrationProcessor implements ProcessorInterface ], 'granted' => $data['granted'], 'rejected' => $data['rejected'], - 'time' => $data['time'] + 'event_time'=> $data['event_time'] ]; } } diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/WebhookWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/WebhookWorker.php index 18f1b8ce18..2f16c87c8d 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/WebhookWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/WebhookWorker.php @@ -160,7 +160,7 @@ class WebhookWorker implements WorkerInterface if (!isset($payload['delivery_id'])) { $webhookData = $webhookevent->getData(); - $webhookData['time'] = $webhookevent->getCreated(); + $webhookData['event_time'] = $webhookevent->getCreated(); $webhookData['url'] = $this->app['conf']->get(['servername'], ''); $webhookData['instance_name'] = $this->app['conf']->get(['registry', 'general', 'title'], ''); // a webhook version is also added when processing data diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index 614c46b0cf..1cd43a632d 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -545,6 +545,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface return $this; } + $beforeCollection = $this->getCollection(); $coll_id_from = $this->getCollectionId(); $coll_id_to = $collection->get_coll_id(); @@ -567,7 +568,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface $this->app['phraseanet.logger']($this->getDatabox()) ->log($this, Session_Logger::EVENT_MOVE, $collection->get_coll_id(), '', $coll_id_from); - $this->dispatch(RecordEvents::COLLECTION_CHANGED, new CollectionChangedEvent($this)); + $this->dispatch(RecordEvents::COLLECTION_CHANGED, new CollectionChangedEvent($this, $beforeCollection, $collection)); return $this; } diff --git a/resources/proxies/__CG__AlchemyPhraseaModelEntitiesApiApplication.php b/resources/proxies/__CG__AlchemyPhraseaModelEntitiesApiApplication.php index fd9cba3cc3..052f50c2ed 100644 --- a/resources/proxies/__CG__AlchemyPhraseaModelEntitiesApiApplication.php +++ b/resources/proxies/__CG__AlchemyPhraseaModelEntitiesApiApplication.php @@ -64,10 +64,10 @@ class ApiApplication extends \Alchemy\Phrasea\Model\Entities\ApiApplication impl public function __sleep() { if ($this->__isInitialized__) { - return ['__isInitialized__', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'id', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'creator', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'type', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'name', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'description', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'website', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'created', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'updated', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'clientId', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'clientSecret', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'nonce', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'redirectUri', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'activated', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'grantPassword', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'accounts', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'webhookUrl']; + return ['__isInitialized__', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'id', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'creator', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'type', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'name', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'description', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'website', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'created', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'updated', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'clientId', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'clientSecret', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'nonce', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'redirectUri', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'activated', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'grantPassword', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'accounts', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'webhookUrl', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'listenedEvents', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'hmacKey', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'webhookUnactivate']; } - return ['__isInitialized__', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'id', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'creator', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'type', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'name', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'description', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'website', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'created', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'updated', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'clientId', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'clientSecret', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'nonce', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'redirectUri', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'activated', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'grantPassword', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'accounts', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'webhookUrl']; + return ['__isInitialized__', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'id', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'creator', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'type', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'name', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'description', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'website', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'created', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'updated', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'clientId', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'clientSecret', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'nonce', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'redirectUri', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'activated', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'grantPassword', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'accounts', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'webhookUrl', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'listenedEvents', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'hmacKey', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\ApiApplication' . "\0" . 'webhookUnactivate']; } /** @@ -507,4 +507,92 @@ class ApiApplication extends \Alchemy\Phrasea\Model\Entities\ApiApplication impl return parent::addAccount($account); } + /** + * {@inheritDoc} + */ + public function setListenedEvents(array $listenedEvents) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setListenedEvents', [$listenedEvents]); + + return parent::setListenedEvents($listenedEvents); + } + + /** + * {@inheritDoc} + */ + public function addListenedEvent($eventName) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addListenedEvent', [$eventName]); + + return parent::addListenedEvent($eventName); + } + + /** + * {@inheritDoc} + */ + public function removeListenedEvent($eventName) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'removeListenedEvent', [$eventName]); + + return parent::removeListenedEvent($eventName); + } + + /** + * {@inheritDoc} + */ + public function getListenedEvents() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getListenedEvents', []); + + return parent::getListenedEvents(); + } + + /** + * {@inheritDoc} + */ + public function getHmacKey() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getHmacKey', []); + + return parent::getHmacKey(); + } + + /** + * {@inheritDoc} + */ + public function setHmacKey($hmacKey) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setHmacKey', [$hmacKey]); + + return parent::setHmacKey($hmacKey); + } + + /** + * {@inheritDoc} + */ + public function isWebhookUnactivate() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'isWebhookUnactivate', []); + + return parent::isWebhookUnactivate(); + } + + /** + * {@inheritDoc} + */ + public function setWebhookUnactivate($webhookUnactivate) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setWebhookUnactivate', [$webhookUnactivate]); + + return parent::setWebhookUnactivate($webhookUnactivate); + } + } diff --git a/resources/proxies/__CG__AlchemyPhraseaModelEntitiesFeedEntry.php b/resources/proxies/__CG__AlchemyPhraseaModelEntitiesFeedEntry.php index ced6ae2482..1be9597ebd 100644 --- a/resources/proxies/__CG__AlchemyPhraseaModelEntitiesFeedEntry.php +++ b/resources/proxies/__CG__AlchemyPhraseaModelEntitiesFeedEntry.php @@ -64,10 +64,10 @@ class FeedEntry extends \Alchemy\Phrasea\Model\Entities\FeedEntry implements \Do public function __sleep() { if ($this->__isInitialized__) { - return ['__isInitialized__', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'id', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'title', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'subtitle', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'authorName', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'authorEmail', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'createdOn', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'updatedOn', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'items', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'publisher', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'feed']; + return ['__isInitialized__', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'id', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'title', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'subtitle', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'authorName', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'authorEmail', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'createdOn', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'updatedOn', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'items', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'publisher', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'feed', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'notifyEmailOn']; } - return ['__isInitialized__', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'id', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'title', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'subtitle', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'authorName', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'authorEmail', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'createdOn', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'updatedOn', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'items', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'publisher', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'feed']; + return ['__isInitialized__', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'id', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'title', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'subtitle', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'authorName', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'authorEmail', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'createdOn', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'updatedOn', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'items', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'publisher', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'feed', '' . "\0" . 'Alchemy\\Phrasea\\Model\\Entities\\FeedEntry' . "\0" . 'notifyEmailOn']; } /** @@ -397,6 +397,28 @@ class FeedEntry extends \Alchemy\Phrasea\Model\Entities\FeedEntry implements \Do return parent::getFeed(); } + /** + * {@inheritDoc} + */ + public function getNotifyEmailOn() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getNotifyEmailOn', []); + + return parent::getNotifyEmailOn(); + } + + /** + * {@inheritDoc} + */ + public function setNotifyEmailOn($notifyEmailOn) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setNotifyEmailOn', [$notifyEmailOn]); + + return parent::setNotifyEmailOn($notifyEmailOn); + } + /** * {@inheritDoc} */ diff --git a/tests/Alchemy/Tests/Phrasea/WorkerManager/Worker/WebhookWorkerTest.php b/tests/Alchemy/Tests/Phrasea/WorkerManager/Worker/WebhookWorkerTest.php index f41d8dd0f9..4bd23ee5ec 100644 --- a/tests/Alchemy/Tests/Phrasea/WorkerManager/Worker/WebhookWorkerTest.php +++ b/tests/Alchemy/Tests/Phrasea/WorkerManager/Worker/WebhookWorkerTest.php @@ -107,7 +107,7 @@ class WebhookWorkerTest extends \PhraseanetTestCase $this->assertEquals(self::$DI['record_1']->get_sbas_id(), $requestBody['data']['databox_id']); $this->assertEquals(self::$DI['record_1']->get_record_id(), $requestBody['data']['record_id']); $this->assertEquals('record', $requestBody['data']['record_type']); - $this->assertArrayHasKey('time', $requestBody); + $this->assertArrayHasKey('event_time', $requestBody); } } @@ -223,7 +223,8 @@ class WebhookWorkerTest extends \PhraseanetTestCase $this->assertInternalType('array', $requestBody); $this->assertArrayHasKey('event', $requestBody); - $this->assertArrayHasKey('time', $requestBody); + $this->assertArrayHasKey('event_time', $requestBody); + $this->assertArrayHasKey('webhookId', $requestBody); switch (true) { case (in_array($requestBody['event'], $this->events[WebhookEvent::RECORD_TYPE])): @@ -232,7 +233,7 @@ class WebhookWorkerTest extends \PhraseanetTestCase $this->assertEquals(self::$DI['record_1']->get_record_id(), $requestBody['data']['record_id']); $this->assertEquals('record', $requestBody['data']['record_type']); $this->assertEquals(self::$DI['record_1']->getCollection()->get_name(), $requestBody['data']['collection_name']); - $this->assertCount(6, $requestBody); + $this->assertCount(7, $requestBody); break; case (in_array($requestBody['event'], $this->events[WebhookEvent::RECORD_SUBDEF_TYPE])): @@ -240,7 +241,7 @@ class WebhookWorkerTest extends \PhraseanetTestCase $this->assertEquals(self::$DI['record_1']->get_sbas_id(), $requestBody['data']['databox_id']); $this->assertEquals(self::$DI['record_1']->get_record_id(), $requestBody['data']['record_id']); $this->assertEquals('thumbnail', $requestBody['data']['subdef']); - $this->assertCount(6, $requestBody); + $this->assertCount(7, $requestBody); break; case (in_array($requestBody['event'], $this->events[WebhookEvent::USER_TYPE])): @@ -249,7 +250,7 @@ class WebhookWorkerTest extends \PhraseanetTestCase $this->assertEquals(self::$DI['user_notAdmin']->getId(), $requestBody['user']['id']); $this->assertEquals('noone_not_admin@example.com', $requestBody['user']['email']); $this->assertEquals('noone_not_admin@example.com', $requestBody['user']['login']); - $this->assertCount(6, $requestBody); + $this->assertCount(7, $requestBody); break; case (in_array($requestBody['event'], $this->events[WebhookEvent::USER_REGISTRATION_TYPE])): @@ -260,7 +261,7 @@ class WebhookWorkerTest extends \PhraseanetTestCase $this->assertEquals(self::$DI['user_notAdmin']->getId(), $requestBody['user']['id']); $this->assertEquals(['rejected'], $requestBody['rejected']); $this->assertEquals(['granted'], $requestBody['granted']); - $this->assertCount(8, $requestBody); + $this->assertCount(9, $requestBody); break; case (in_array($requestBody['event'], $this->events[WebhookEvent::FEED_ENTRY_TYPE])): @@ -268,7 +269,7 @@ class WebhookWorkerTest extends \PhraseanetTestCase $this->assertArrayHasKey('feed', $requestBody); $this->assertArrayHasKey('entry', $requestBody); $this->assertEquals(self::$DI['feed_public_entry']->getId(), $requestBody['entry']['id']); - $this->assertCount(9, $requestBody); + $this->assertCount(10, $requestBody); break; case (in_array($requestBody['event'], $this->events[WebhookEvent::ORDER_TYPE])): @@ -276,7 +277,7 @@ class WebhookWorkerTest extends \PhraseanetTestCase $this->assertArrayHasKey('user', $requestBody); $this->assertArrayHasKey('order', $requestBody); $this->assertEquals(self::$DI['user_notAdmin']->getId(), $requestBody['user']['id']); - $this->assertCount(7, $requestBody); + $this->assertCount(8, $requestBody); break; }