diff --git a/bin/console b/bin/console index 2dcc02e275..0f315afa68 100755 --- a/bin/console +++ b/bin/console @@ -160,9 +160,9 @@ $cli->command(new QueryParseCommand()); $cli->command(new QuerySampleCommand()); $cli->command(new FindConceptsCommand()); -$cli->command($cli['alchemy_worker.commands.run_dispatcher_command']); -$cli->command($cli['alchemy_worker.commands.run_worker_command']); -$cli->command($cli['alchemy_worker.commands.show_configuration']); +//$cli->command($cli['alchemy_worker.commands.run_dispatcher_command']); +//$cli->command($cli['alchemy_worker.commands.run_worker_command']); +//$cli->command($cli['alchemy_worker.commands.show_configuration']); $cli->loadPlugins(); diff --git a/lib/Alchemy/Phrasea/Border/Manager.php b/lib/Alchemy/Phrasea/Border/Manager.php index d8abc9ac99..d017d206e6 100644 --- a/lib/Alchemy/Phrasea/Border/Manager.php +++ b/lib/Alchemy/Phrasea/Border/Manager.php @@ -14,6 +14,8 @@ namespace Alchemy\Phrasea\Border; use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Border\Checker\CheckerInterface; use Alchemy\Phrasea\Border\Attribute\AttributeInterface; +use Alchemy\Phrasea\Core\Event\Record\RecordEvents; +use Alchemy\Phrasea\Core\Event\Record\SubdefinitionCreateEvent; use Alchemy\Phrasea\Exception\RuntimeException; use Alchemy\Phrasea\Metadata\Tag\TfArchivedate; use Alchemy\Phrasea\Metadata\Tag\TfQuarantine; @@ -333,7 +335,7 @@ class Manager $this->app['phraseanet.metadata-setter']->replaceMetadata($newMetadata, $element); if(!$nosubdef) { - $element->rebuild_subdefs(); + $this->app['dispatcher']->dispatch(RecordEvents::SUBDEFINITION_CREATE, new SubdefinitionCreateEvent($element, true)); } return $element; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/ExportController.php b/lib/Alchemy/Phrasea/Controller/Prod/ExportController.php index df6f2a9f19..f4692c99ac 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/ExportController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/ExportController.php @@ -15,6 +15,7 @@ use Alchemy\Phrasea\Application\Helper\FilesystemAware; use Alchemy\Phrasea\Application\Helper\NotifierAware; use Alchemy\Phrasea\Controller\Controller; use Alchemy\Phrasea\Core\Event\ExportFailureEvent; +use Alchemy\Phrasea\Core\Event\ExportMailEvent; use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Exception\InvalidArgumentException; use Alchemy\Phrasea\Model\Manipulator\TokenManipulator; @@ -193,42 +194,26 @@ class ExportController extends Controller $token = $this->getTokenManipulator()->createEmailExportToken(serialize($list)); if (count($destMails) > 0) { - //zip documents - \set_export::build_zip( - $this->app, - $token, - $list, - $this->app['tmp.download.path'].'/'. $token->getValue() . '.zip' - ); + $emitterId = $this->getAuthenticatedUser()->getId(); - $remaingEmails = $destMails; + $tokenValue = $token->getValue(); $url = $this->app->url('prepare_download', ['token' => $token->getValue(), 'anonymous' => false, 'type' => \Session_Logger::EVENT_EXPORTMAIL]); - $user = $this->getAuthenticatedUser(); - $emitter = new Emitter($user->getDisplayName(), $user->getEmail()); + $params = [ + 'url' => $url, + 'textmail' => $request->request->get('textmail'), + 'reading_confirm' => !!$request->request->get('reading_confirm', false), + 'ssttid' => $ssttid = $request->request->get('ssttid', ''), + 'lst' => $lst = $request->request->get('lst', ''), + ]; - foreach ($destMails as $key => $mail) { - try { - $receiver = new Receiver(null, trim($mail)); - } catch (InvalidArgumentException $e) { - continue; - } - - $mail = MailRecordsExport::create($this->app, $receiver, $emitter, $request->request->get('textmail')); - $mail->setButtonUrl($url); - $mail->setExpiration($token->getExpiration()); - - $this->deliver($mail, !!$request->request->get('reading_confirm', false)); - unset($remaingEmails[$key]); - } - - //some mails failed - if (count($remaingEmails) > 0) { - foreach ($remaingEmails as $mail) { - $this->dispatch(PhraseaEvents::EXPORT_MAIL_FAILURE, new ExportFailureEvent($this->getAuthenticatedUser(), $ssttid, $lst, \eventsmanager_notify_downloadmailfail::MAIL_FAIL, $mail)); - } - } + $this->dispatch(PhraseaEvents::EXPORT_MAIL_CREATE, new ExportMailEvent( + $emitterId, + $tokenValue, + $destMails, + $params + )); } return $this->app->json([ diff --git a/lib/Alchemy/Phrasea/Controller/Prod/RecordController.php b/lib/Alchemy/Phrasea/Controller/Prod/RecordController.php index 0a948d6d1d..8e9a609811 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/RecordController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/RecordController.php @@ -14,6 +14,8 @@ use Alchemy\Phrasea\Application\Helper\EntityManagerAware; use Alchemy\Phrasea\Application\Helper\SearchEngineAware; use Alchemy\Phrasea\Controller\Controller; use Alchemy\Phrasea\Controller\RecordsRequest; +use Alchemy\Phrasea\Core\Event\Record\DeleteEvent; +use Alchemy\Phrasea\Core\Event\Record\RecordEvents; use Alchemy\Phrasea\Core\Event\RecordEdit; use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Model\Entities\BasketElement; @@ -234,7 +236,7 @@ class RecordController extends Controller if($trashCollectionsBySbasId[$sbasId] !== null) { if($record->getCollection()->get_coll_id() == $trashCollectionsBySbasId[$sbasId]->get_coll_id()) { // record is already in trash so delete it - $record->delete(); + $this->getEventDispatcher()->dispatch(RecordEvents::DELETE, new DeleteEvent($record)); } else { // move to trash collection $record->move_to_collection($trashCollectionsBySbasId[$sbasId], $this->getApplicationBox()); @@ -247,7 +249,7 @@ class RecordController extends Controller } } else { // no trash collection, delete - $record->delete(); + $this->getEventDispatcher()->dispatch(RecordEvents::DELETE, new DeleteEvent($record)); } } catch (\Exception $e) { } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/StoryController.php b/lib/Alchemy/Phrasea/Controller/Prod/StoryController.php index 9a65ed61fa..a90f0a0ed1 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/StoryController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/StoryController.php @@ -14,6 +14,8 @@ use Alchemy\Phrasea\Application\Helper\EntityManagerAware; use Alchemy\Phrasea\Controller\Controller; use Alchemy\Phrasea\Controller\RecordsRequest; use Alchemy\Phrasea\Controller\Exception as ControllerException; +use Alchemy\Phrasea\Core\Event\Record\RecordEvents; +use Alchemy\Phrasea\Core\Event\Record\SubdefinitionCreateEvent; use Alchemy\Phrasea\Core\Event\RecordEdit; use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Model\Entities\StoryWZ; @@ -68,7 +70,9 @@ class StoryController extends Controller break; } - $story->set_metadatas($metadatas)->rebuild_subdefs(); + $recordAdapter = $story->set_metadatas($metadatas); + // tell phraseanet to rebuild subdef + $this->dispatch(RecordEvents::SUBDEFINITION_CREATE, new SubdefinitionCreateEvent($recordAdapter)); $storyWZ = new StoryWZ(); $storyWZ->setUser($this->getAuthenticatedUser()); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php b/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php index 872f385455..65f72a8a36 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php @@ -16,6 +16,7 @@ use Alchemy\Phrasea\Application\Helper\SubDefinitionSubstituerAware; use Alchemy\Phrasea\Controller\Controller; use Alchemy\Phrasea\Controller\RecordsRequest; use Alchemy\Phrasea\Core\Event\Record\RecordEvents; +use Alchemy\Phrasea\Core\Event\Record\SubdefinitionCreateEvent; use Alchemy\Phrasea\Exception\RuntimeException; use Alchemy\Phrasea\Metadata\PhraseanetMetadataReader; use Alchemy\Phrasea\Metadata\PhraseanetMetadataSetter; @@ -156,7 +157,7 @@ class ToolsController extends Controller } if (!$substituted || $force) { - $record->rebuild_subdefs(); + $this->dispatch(RecordEvents::SUBDEFINITION_CREATE, new SubdefinitionCreateEvent($record)); } } diff --git a/lib/Alchemy/Phrasea/Core/Event/ExportMailEvent.php b/lib/Alchemy/Phrasea/Core/Event/ExportMailEvent.php new file mode 100644 index 0000000000..3acafb4c70 --- /dev/null +++ b/lib/Alchemy/Phrasea/Core/Event/ExportMailEvent.php @@ -0,0 +1,53 @@ +emitterUserId = $emitterUserId; + $this->tokenValue = $tokenValue; + $this->destinationMails = $destMails; + $this->params = $params; + } + + public function getTokenValue() + { + return $this->tokenValue; + } + + public function getDestinationMails() + { + return $this->destinationMails; + } + + public function getEmitterUserId() + { + return $this->emitterUserId; + } + + public function getParams() + { + return $this->params; + } +} diff --git a/lib/Alchemy/Phrasea/Core/Event/Record/DeleteEvent.php b/lib/Alchemy/Phrasea/Core/Event/Record/DeleteEvent.php new file mode 100644 index 0000000000..8d8bfdb379 --- /dev/null +++ b/lib/Alchemy/Phrasea/Core/Event/Record/DeleteEvent.php @@ -0,0 +1,7 @@ +isNewRecord = $isNewRecord; + } + + /** + * @return bool + */ + public function isNewRecord() + { + return $this->isNewRecord; + } +} diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ExportSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ExportSubscriber.php index fca66dab4a..d3c05a64b6 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ExportSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ExportSubscriber.php @@ -12,7 +12,15 @@ namespace Alchemy\Phrasea\Core\Event\Subscriber; use Alchemy\Phrasea\Core\Event\ExportFailureEvent; +use Alchemy\Phrasea\Core\Event\ExportMailEvent; use Alchemy\Phrasea\Core\PhraseaEvents; +use Alchemy\Phrasea\Exception\InvalidArgumentException; +use Alchemy\Phrasea\Model\Entities\Token; +use Alchemy\Phrasea\Model\Repositories\TokenRepository; +use Alchemy\Phrasea\Model\Repositories\UserRepository; +use Alchemy\Phrasea\Notification\Emitter; +use Alchemy\Phrasea\Notification\Mail\MailRecordsExport; +use Alchemy\Phrasea\Notification\Receiver; class ExportSubscriber extends AbstractNotificationSubscriber { @@ -39,10 +47,65 @@ class ExportSubscriber extends AbstractNotificationSubscriber $this->app['event-manager']->notify($params['usr_id'], 'eventsmanager_notify_downloadmailfail', $datas, $mailed); } + public function onCreateExportMail(ExportMailEvent $event) + { + $destMails = $event->getDestinationMails(); + + $params = $event->getParams(); + + /** @var UserRepository $userRepository */ + $userRepository = $this->app['repo.users']; + + $user = $userRepository->find($event->getEmitterUserId()); + + /** @var TokenRepository $tokenRepository */ + $tokenRepository = $this->app['repo.tokens']; + + /** @var Token $token */ + $token = $tokenRepository->findValidToken($event->getTokenValue()); + + $list = unserialize($token->getData()); + + //zip documents + \set_export::build_zip( + $this->app, + $token, + $list, + $this->app['tmp.download.path'].'/'. $token->getValue() . '.zip' + ); + + $remaingEmails = $destMails; + + $emitter = new Emitter($user->getDisplayName(), $user->getEmail()); + + foreach ($destMails as $key => $mail) { + try { + $receiver = new Receiver(null, trim($mail)); + } catch (InvalidArgumentException $e) { + continue; + } + + $mail = MailRecordsExport::create($this->app, $receiver, $emitter, $params['textmail']); + $mail->setButtonUrl($params['url']); + $mail->setExpiration($token->getExpiration()); + + $this->deliver($mail, $params['reading_confirm']); + unset($remaingEmails[$key]); + } + + //some mails failed + if (count($remaingEmails) > 0) { + foreach ($remaingEmails as $mail) { + $this->app['dispatcher']->dispatch(PhraseaEvents::EXPORT_MAIL_FAILURE, new ExportFailureEvent($user, $params['ssttid'], $params['lst'], \eventsmanager_notify_downloadmailfail::MAIL_FAIL, $mail)); + } + } + } + public static function getSubscribedEvents() { return [ - PhraseaEvents::EXPORT_MAIL_FAILURE => 'onMailExportFailure' + PhraseaEvents::EXPORT_MAIL_FAILURE => 'onMailExportFailure', + PhraseaEvents::EXPORT_MAIL_CREATE => 'onCreateExportMail', ]; } } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/RecordEditSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/RecordEditSubscriber.php index d5c0c69f54..8307749eb5 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/RecordEditSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/RecordEditSubscriber.php @@ -11,8 +11,10 @@ namespace Alchemy\Phrasea\Core\Event\Subscriber; use Alchemy\Phrasea\Core\Event\Record\CollectionChangedEvent; +use Alchemy\Phrasea\Core\Event\Record\DeleteEvent; use Alchemy\Phrasea\Core\Event\Record\RecordEvent; use Alchemy\Phrasea\Core\Event\Record\RecordEvents; +use Alchemy\Phrasea\Core\Event\Record\SubdefinitionCreateEvent; use Alchemy\Phrasea\Core\Event\RecordEdit; use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Metadata\Tag\TfEditdate; @@ -26,10 +28,12 @@ class RecordEditSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { return array( - PhraseaEvents::RECORD_EDIT => 'onEdit', - PhraseaEvents::RECORD_UPLOAD => 'onEdit', - RecordEvents::ROTATE => 'onRecordChange', - RecordEvents::COLLECTION_CHANGED => 'onCollectionChanged', + PhraseaEvents::RECORD_EDIT => 'onEdit', + PhraseaEvents::RECORD_UPLOAD => 'onEdit', + RecordEvents::ROTATE => 'onRecordChange', + RecordEvents::COLLECTION_CHANGED => 'onCollectionChanged', + RecordEvents::SUBDEFINITION_CREATE => 'onSubdefinitionCreate', + RecordEvents::DELETE => 'onDelete', ); } @@ -49,6 +53,18 @@ class RecordEditSubscriber implements EventSubscriberInterface $recordAdapter->clearStampCache(); } + public function onSubdefinitionCreate(SubdefinitionCreateEvent $event) + { + $recordAdapter = $this->convertToRecordAdapter($event->getRecord()); + $recordAdapter->rebuild_subdefs(); + } + + public function onDelete(DeleteEvent $event) + { + $recordAdapter = $this->convertToRecordAdapter($event->getRecord()); + $recordAdapter->delete(); + } + public function onEdit(RecordEdit $event) { static $into = false; diff --git a/lib/Alchemy/Phrasea/Core/PhraseaEvents.php b/lib/Alchemy/Phrasea/Core/PhraseaEvents.php index 97c9c10ba5..90adac69dd 100644 --- a/lib/Alchemy/Phrasea/Core/PhraseaEvents.php +++ b/lib/Alchemy/Phrasea/Core/PhraseaEvents.php @@ -48,7 +48,8 @@ final class PhraseaEvents const BRIDGE_UPLOAD_FAILURE = 'bridge.upload-failure'; const EXPORT_MAIL_FAILURE = 'export.mail-failure'; - const EXPORT_CREATE = 'export.create'; + const EXPORT_CREATE = 'export.create'; + const EXPORT_MAIL_CREATE = 'export.mail-create'; const RECORD_EDIT = 'record.edit'; const RECORD_UPLOAD = 'record.upload'; diff --git a/lib/Alchemy/Phrasea/Core/Provider/WorkerConfigurationServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/WorkerConfigurationServiceProvider.php index 1b2e15d4f0..9931d4649f 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/WorkerConfigurationServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/WorkerConfigurationServiceProvider.php @@ -32,11 +32,12 @@ class WorkerConfigurationServiceProvider implements ServiceProviderInterface $app['alchemy_queues.queues'] = $app->share(function (Application $app) { $defaultConfiguration = [ 'worker-queue' => [ - 'registry' => 'alchemy_worker.queue_registry', - 'host' => 'localhost', - 'port' => 5672, - 'user' => 'guest', - 'vhost' => '/' + 'registry' => 'alchemy_worker.queue_registry', + 'host' => 'localhost', + 'port' => 5672, + 'user' => 'guest', + 'password' => 'guest', + 'vhost' => '/' ] ]; @@ -46,19 +47,22 @@ class WorkerConfigurationServiceProvider implements ServiceProviderInterface $queueConfigurations = $configuration->get(['workers', 'queue'], $defaultConfiguration); - $queueConfiguration = reset($queueConfigurations); - $queueKey = key($queueConfigurations); + $config = []; - if (! isset($queueConfiguration['name'])) { - if (! is_string($queueKey)) { - throw new \RuntimeException('Invalid queue configuration: configuration has no key or name.'); + foreach($queueConfigurations as $name => $queueConfiguration) { + $queueKey = $name; + + if (! isset($queueConfiguration['name'])) { + if (! is_string($queueKey)) { + throw new \RuntimeException('Invalid queue configuration: configuration has no key or name.'); + } + + $queueConfiguration['name'] = $queueKey; } - $queueConfiguration['name'] = $queueKey; + $config[$queueConfiguration['name']] = $queueConfiguration ; } - $config = [ $queueConfiguration['name'] => $queueConfiguration ]; - return $config; } catch (RuntimeException $exception) { diff --git a/lib/Alchemy/Phrasea/Media/SubdefGenerator.php b/lib/Alchemy/Phrasea/Media/SubdefGenerator.php index 88867551a1..9612e3bc19 100644 --- a/lib/Alchemy/Phrasea/Media/SubdefGenerator.php +++ b/lib/Alchemy/Phrasea/Media/SubdefGenerator.php @@ -18,6 +18,7 @@ use Alchemy\Phrasea\Core\Event\Record\SubDefinitionCreationEvent; use Alchemy\Phrasea\Core\Event\Record\SubDefinitionsCreationEvent; use Alchemy\Phrasea\Core\Event\Record\SubDefinitionCreationFailedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordEvents; +use Alchemy\Phrasea\Databox\Subdef\MediaSubdefRepository; use Alchemy\Phrasea\Filesystem\FilesystemService; use Alchemy\Phrasea\Media\Subdef\Specification\PdfSpecification; use MediaAlchemyst\Alchemyst; @@ -170,13 +171,53 @@ class SubdefGenerator unset($this->tmpFilePath); } - $this->dispatch( - RecordEvents::SUB_DEFINITIONS_CREATED, - new SubDefinitionsCreatedEvent( - $record, - $mediaCreated - ) - ); + // if we created subdef one by one + if (count($wanted_subdefs) == 1) { + $mediaSubdefRepository = $this->getMediaSubdefRepository($record->getDataboxId()); + $mediaSubdefs = $mediaSubdefRepository->findByRecordIdsAndNames([$record->getRecordId()]); + $medias = []; + foreach ($mediaSubdefs as $subdef) { + try { + $medias[$subdef->get_name()] = $this->mediavorus->guess($subdef->getRealPath()); + } catch (MediaVorusFileNotFoundException $e) { + + } + } + + $this->dispatch( + RecordEvents::SUB_DEFINITIONS_CREATED, + new SubDefinitionsCreatedEvent( + $record, + $medias + ) + ); + } else { + $this->dispatch( + RecordEvents::SUB_DEFINITIONS_CREATED, + new SubDefinitionsCreatedEvent( + $record, + $mediaCreated + ) + ); + } + } + + /** + * set a logger to use + * @param LoggerInterface $logger + */ + public function setLogger(LoggerInterface $logger) + { + $this->logger = $logger; + } + + /** + * to get the logger + * @return LoggerInterface + */ + public function getLogger() + { + return $this->logger; } private function generateSubdef(\record_adapter $record, \databox_subdef $subdef_class, $pathdest) @@ -276,4 +317,14 @@ class SubdefGenerator $i = floor(log($bytes, 1024)); return round($bytes / pow(1024, $i), [0,0,2,2,3][$i]).['B','kB','MB','GB'][$i]; } + + /** + * @param $databoxId + * + * @return MediaSubdefRepository|Object + */ + private function getMediaSubdefRepository($databoxId) + { + return $this->app['provider.repo.media_subdef']->getRepositoryForDatabox($databoxId); + } } diff --git a/lib/Alchemy/Phrasea/Media/SubdefSubstituer.php b/lib/Alchemy/Phrasea/Media/SubdefSubstituer.php index 2259fa572d..8f7aa61e90 100644 --- a/lib/Alchemy/Phrasea/Media/SubdefSubstituer.php +++ b/lib/Alchemy/Phrasea/Media/SubdefSubstituer.php @@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Media; use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Core\Event\Record\MediaSubstitutedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordEvents; +use Alchemy\Phrasea\Core\Event\Record\SubdefinitionCreateEvent; use Alchemy\Phrasea\Filesystem\FilesystemService; use MediaAlchemyst\Alchemyst; use MediaAlchemyst\Exception\ExceptionInterface as MediaAlchemystException; @@ -79,7 +80,7 @@ class SubdefSubstituer $record->write_metas(); if ($shouldSubdefsBeRebuilt) { - $record->rebuild_subdefs(); + $this->dispatcher->dispatch(RecordEvents::SUBDEFINITION_CREATE, new SubdefinitionCreateEvent($record)); } $this->dispatcher->dispatch(RecordEvents::MEDIA_SUBSTITUTED, new MediaSubstitutedEvent($record)); diff --git a/lib/Alchemy/Phrasea/Model/Manipulator/WebhookEventManipulator.php b/lib/Alchemy/Phrasea/Model/Manipulator/WebhookEventManipulator.php index 40e7f812a7..30d20d1045 100644 --- a/lib/Alchemy/Phrasea/Model/Manipulator/WebhookEventManipulator.php +++ b/lib/Alchemy/Phrasea/Model/Manipulator/WebhookEventManipulator.php @@ -12,7 +12,7 @@ namespace Alchemy\Phrasea\Model\Manipulator; use Alchemy\Phrasea\Model\Entities\WebhookEvent; -use Alchemy\Phrasea\Webhook\WebhookPublisher; +use Alchemy\Phrasea\Webhook\WebhookPublisherInterface; use Doctrine\Common\Persistence\ObjectManager; use Doctrine\ORM\EntityRepository; @@ -29,11 +29,11 @@ class WebhookEventManipulator implements ManipulatorInterface private $repository; /** - * @var WebhookPublisher + * @var WebhookPublisherInterface */ private $publisher; - public function __construct(ObjectManager $om, EntityRepository $repo, WebhookPublisher $publisher) + public function __construct(ObjectManager $om, EntityRepository $repo, WebhookPublisherInterface $publisher) { $this->om = $om; $this->repository = $repo; diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php index 532eb8bbb5..de418a4e71 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php @@ -12,6 +12,8 @@ namespace Alchemy\Phrasea\TaskManager\Job; use Alchemy\Phrasea\Application; +use Alchemy\Phrasea\Core\Event\Record\RecordEvents; +use Alchemy\Phrasea\Core\Event\Record\SubdefinitionCreateEvent; use Alchemy\Phrasea\Exception\RuntimeException; use Alchemy\Phrasea\Border\File; use Alchemy\Phrasea\Border\Manager as borderManager; @@ -1001,7 +1003,7 @@ class ArchiveJob extends AbstractJob { // quick fix to reconnect if mysql is lost $app->getApplicationBox()->get_connection(); - $databox->get_connection(); + $collection->get_connection(); $status = \databox_status::operation_or($stat0, $stat1); @@ -1032,7 +1034,8 @@ class ArchiveJob extends AbstractJob } $story->setStatus(\databox_status::operation_or($stat0, $stat1)); - $story->rebuild_subdefs(); + + $app['dispatcher']->dispatch(RecordEvents::SUBDEFINITION_CREATE, new SubdefinitionCreateEvent($story)); unset($media); diff --git a/lib/Alchemy/Phrasea/Webhook/WebhookPublisher.php b/lib/Alchemy/Phrasea/Webhook/WebhookPublisher.php index 4304a5319f..2beaec292f 100644 --- a/lib/Alchemy/Phrasea/Webhook/WebhookPublisher.php +++ b/lib/Alchemy/Phrasea/Webhook/WebhookPublisher.php @@ -19,7 +19,7 @@ use Alchemy\Queue\MessageQueueRegistry; * Class WebhookPublisher publishes webhook event notifications in message queues * @package Alchemy\Phrasea\Webhook */ -class WebhookPublisher +class WebhookPublisher implements WebhookPublisherInterface { /** * @var MessageQueueRegistry diff --git a/lib/Alchemy/Phrasea/Webhook/WebhookPublisherInterface.php b/lib/Alchemy/Phrasea/Webhook/WebhookPublisherInterface.php new file mode 100644 index 0000000000..f8b4751ef0 --- /dev/null +++ b/lib/Alchemy/Phrasea/Webhook/WebhookPublisherInterface.php @@ -0,0 +1,10 @@ +getDataboxConnection()->executeUpdate($sql, ['type' => $type, 'record_id' => $this->getRecordId()]); if ($old_type !== $type) { - $this->rebuild_subdefs(); + $this->dispatch(RecordEvents::SUBDEFINITION_CREATE, new SubdefinitionCreateEvent($this)); } $this->type = $type; @@ -341,7 +342,8 @@ class record_adapter implements RecordInterface, cache_cacheableInterface array(':mime' => $mime, ':record_id' => $this->getRecordId()) )) { - $this->rebuild_subdefs(); + $this->dispatch(RecordEvents::SUBDEFINITION_CREATE, new SubdefinitionCreateEvent($this)); + $this->delete_data_from_cache(); } diff --git a/resources/locales/messages.en.xlf b/resources/locales/messages.en.xlf index 4c9560d4e9..4b5369e3e6 100644 --- a/resources/locales/messages.en.xlf +++ b/resources/locales/messages.en.xlf @@ -1,4 +1,4 @@ - +
@@ -7,8 +7,8 @@
- - + + Form/Login/PhraseaAuthenticationForm.php Form/Configuration/EmailFormType.php @@ -13432,14 +13432,14 @@ It is possible to place several search areas August prod/WorkZone/Basket.html.twig - + workzone:datepicker:closeText - workzone:datepicker:closeText + Close prod/WorkZone/Basket.html.twig - + workzone:datepicker:currentText - workzone:datepicker:currentText + Current prod/WorkZone/Basket.html.twig @@ -13543,9 +13543,9 @@ It is possible to place several search areas prod/WorkZone/Basket.html.twig prod/Tooltip/Basket.html.twig - + workzone:feedback:expiration-open - workzone:feedback:expiration-open + Feedback open until prod/WorkZone/Basket.html.twig prod/Tooltip/Basket.html.twig diff --git a/resources/locales/messages.fr.xlf b/resources/locales/messages.fr.xlf index be1a6c9a97..d830633044 100644 --- a/resources/locales/messages.fr.xlf +++ b/resources/locales/messages.fr.xlf @@ -1,4 +1,4 @@ - +
@@ -7,8 +7,8 @@
- - + + Form/Login/PhraseaAuthenticationForm.php Form/Configuration/EmailFormType.php @@ -13540,15 +13540,15 @@ Si vous recevez cet e-mail sans l'avoir sollicité, merci de l'ignorer ou de le Mercredi prod/WorkZone/Basket.html.twig
- + workzone:feedback:expiration-closed - workzone:feedback:expiration-closed + Validation close depuis prod/WorkZone/Basket.html.twig prod/Tooltip/Basket.html.twig - + workzone:feedback:expiration-open - workzone:feedback:expiration-open + validation ouverte jusqu'au prod/WorkZone/Basket.html.twig prod/Tooltip/Basket.html.twig diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/ExportTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/ExportTest.php index 886df13e81..e49a967d0c 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/ExportTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/ExportTest.php @@ -169,7 +169,8 @@ class ExportTest extends \PhraseanetAuthenticatedWebTestCase */ public function testExportMail() { - $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRecordsExport'); + // deliver method removed in the listener +// $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRecordsExport'); $this->getClient()->request('POST', '/prod/export/mail/', [ 'lst' => $this->getRecord1()->getId(),