Move RECORD_* events in a new RecordEvents class

This commit is contained in:
Mathieu Darse
2015-01-27 16:17:48 +01:00
parent 85c410278a
commit a1d6fc03b6
19 changed files with 72 additions and 51 deletions

View File

@@ -13,8 +13,8 @@ namespace Alchemy\Phrasea\Border;
use Alchemy\Phrasea\Border\Checker\CheckerInterface; use Alchemy\Phrasea\Border\Checker\CheckerInterface;
use Alchemy\Phrasea\Border\Attribute\AttributeInterface; use Alchemy\Phrasea\Border\Attribute\AttributeInterface;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Metadata\Tag\TfArchivedate; use Alchemy\Phrasea\Metadata\Tag\TfArchivedate;
use Alchemy\Phrasea\Metadata\Tag\TfQuarantine; use Alchemy\Phrasea\Metadata\Tag\TfQuarantine;
use Alchemy\Phrasea\Metadata\Tag\TfBasename; use Alchemy\Phrasea\Metadata\Tag\TfBasename;
@@ -290,7 +290,7 @@ class Manager
case AttributeInterface::NAME_STATUS: case AttributeInterface::NAME_STATUS:
$element->set_binary_status(decbin(bindec($element->get_status()) | bindec($attribute->getValue()))); $element->set_binary_status(decbin(bindec($element->get_status()) | bindec($attribute->getValue())));
$this->app['dispatcher']->dispatch(PhraseaEvents::RECORD_STATUS_CHANGED, new RecordStatusChangedEvent($element)); $this->app['dispatcher']->dispatch(RecordEvents::STATUS_CHANGED, new RecordStatusChangedEvent($element));
break; break;
case AttributeInterface::NAME_STORY: case AttributeInterface::NAME_STORY:

View File

@@ -14,7 +14,7 @@ namespace Alchemy\Phrasea\Command;
use Alchemy\Phrasea\Border\File; use Alchemy\Phrasea\Border\File;
use Alchemy\Phrasea\Border\Manager; use Alchemy\Phrasea\Border\Manager;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent;
use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use Alchemy\Phrasea\Model\Entities\LazaretFile; use Alchemy\Phrasea\Model\Entities\LazaretFile;
use Alchemy\Phrasea\Model\Entities\LazaretSession; use Alchemy\Phrasea\Model\Entities\LazaretSession;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
@@ -117,7 +117,7 @@ class RecordAdd extends Command
"Record id <info>%d</info> on collection `%s` (databox `%s`) has been created", $elementCreated->get_record_id(), $elementCreated->get_collection()->get_label($this->container['locale']), $elementCreated->get_databox()->get_label($this->container['locale']) "Record id <info>%d</info> on collection `%s` (databox `%s`) has been created", $elementCreated->get_record_id(), $elementCreated->get_collection()->get_label($this->container['locale']), $elementCreated->get_databox()->get_label($this->container['locale'])
) )
); );
$this->container['dispatcher']->dispatch(PhraseaEvents::RECORD_CREATED, new RecordCreatedEvent($elementCreated)); $this->container['dispatcher']->dispatch(RecordEvents::CREATED, new RecordCreatedEvent($elementCreated));
} elseif ($elementCreated instanceof LazaretFile) { } elseif ($elementCreated instanceof LazaretFile) {
$output->writeln( $output->writeln(
sprintf("Quarantine item id <info>%d</info> has been created", $elementCreated->getId()) sprintf("Quarantine item id <info>%d</info> has been created", $elementCreated->getId())

View File

@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Controller\Api; namespace Alchemy\Phrasea\Controller\Api;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent;
use Silex\ControllerProviderInterface; use Silex\ControllerProviderInterface;
@@ -562,7 +563,7 @@ class V1 implements ControllerProviderInterface
$ret['entity'] = '0'; $ret['entity'] = '0';
$ret['url'] = '/records/' . $output->get_sbas_id() . '/' . $output->get_record_id() . '/'; $ret['url'] = '/records/' . $output->get_sbas_id() . '/' . $output->get_record_id() . '/';
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_CREATED, new RecordCreatedEvent($output)); $app['dispatcher']->dispatch(RecordEvents::CREATED, new RecordCreatedEvent($output));
} }
if ($output instanceof LazaretFile) { if ($output instanceof LazaretFile) {
$ret['entity'] = '1'; $ret['entity'] = '1';
@@ -833,7 +834,7 @@ class V1 implements ControllerProviderInterface
}); });
$record->set_metadatas($metadatas); $record->set_metadatas($metadatas);
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_METADATA_CHANGED, new RecordMetadataChangedEvent($record)); $app['dispatcher']->dispatch(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($record));
return Result::create($request, ["record_metadatas" => $this->list_record_caption($record->get_caption())])->createResponse(); return Result::create($request, ["record_metadatas" => $this->list_record_caption($record->get_caption())])->createResponse();
} }
@@ -867,7 +868,7 @@ class V1 implements ControllerProviderInterface
$record->set_binary_status(strrev($datas)); $record->set_binary_status(strrev($datas));
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_STATUS_CHANGED, new RecordStatusChangedEvent($record)); $app['dispatcher']->dispatch(RecordEvents::STATUS_CHANGED, new RecordStatusChangedEvent($record));
$ret = ["status" => $this->list_record_status($databox, $record->get_status())]; $ret = ["status" => $this->list_record_status($databox, $record->get_status())];

View File

@@ -11,9 +11,9 @@
namespace Alchemy\Phrasea\Controller\Prod; namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Vocabulary\Controller as VocabularyController; use Alchemy\Phrasea\Vocabulary\Controller as VocabularyController;
use Alchemy\Phrasea\Controller\RecordsRequest; use Alchemy\Phrasea\Controller\RecordsRequest;
use Alchemy\Phrasea\Metadata\Tag\TfEditdate; use Alchemy\Phrasea\Metadata\Tag\TfEditdate;
@@ -351,7 +351,7 @@ class Edit implements ControllerProviderInterface
if (isset($rec['metadatas']) && is_array($rec['metadatas'])) { if (isset($rec['metadatas']) && is_array($rec['metadatas'])) {
$record->set_metadatas($rec['metadatas']); $record->set_metadatas($rec['metadatas']);
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_METADATA_CHANGED, new RecordMetadataChangedEvent($record)); $app['dispatcher']->dispatch(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($record));
} }
/** /**
@@ -378,7 +378,7 @@ class Edit implements ControllerProviderInterface
$record->set_metadatas($metas, true); $record->set_metadatas($metas, true);
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_METADATA_CHANGED, new RecordMetadataChangedEvent($record)); $app['dispatcher']->dispatch(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($record));
} }
$newstat = $record->get_status(); $newstat = $record->get_status();
@@ -397,7 +397,7 @@ class Edit implements ControllerProviderInterface
$record->set_binary_status($newstat); $record->set_binary_status($newstat);
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_STATUS_CHANGED, new RecordStatusChangedEvent($record)); $app['dispatcher']->dispatch(RecordEvents::STATUS_CHANGED, new RecordStatusChangedEvent($record));
} }
$record $record

View File

@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Controller\Prod; namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent;
use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Core\PhraseaEvents;
@@ -199,7 +200,7 @@ class Lazaret implements ControllerProviderInterface
$lazaretFile->getSession(), $borderFile, $callBack, Border\Manager::FORCE_RECORD $lazaretFile->getSession(), $borderFile, $callBack, Border\Manager::FORCE_RECORD
); );
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_CREATED, new RecordCreatedEvent($record)); $app['dispatcher']->dispatch(RecordEvents::CREATED, new RecordCreatedEvent($record));
if ($keepAttributes) { if ($keepAttributes) {
//add attribute //add attribute
@@ -234,7 +235,7 @@ class Lazaret implements ControllerProviderInterface
case AttributeInterface::NAME_STATUS: case AttributeInterface::NAME_STATUS:
$record->set_binary_status($attribute->getValue()); $record->set_binary_status($attribute->getValue());
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_STATUS_CHANGED, new RecordStatusChangedEvent($record)); $app['dispatcher']->dispatch(RecordEvents::STATUS_CHANGED, new RecordStatusChangedEvent($record));
break; break;
case AttributeInterface::NAME_METAFIELD: case AttributeInterface::NAME_METAFIELD:
$metaFields->set($attribute->getField()->get_name(), $attribute->getValue()); $metaFields->set($attribute->getField()->get_name(), $attribute->getValue());
@@ -248,7 +249,7 @@ class Lazaret implements ControllerProviderInterface
$fields = $metaFields->toMetadataArray($record->get_databox()->get_meta_structure()); $fields = $metaFields->toMetadataArray($record->get_databox()->get_meta_structure());
$record->set_metadatas($fields); $record->set_metadatas($fields);
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_METADATA_CHANGED, new RecordMetadataChangedEvent($record)); $app['dispatcher']->dispatch(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($record));
} }
//Delete lazaret file //Delete lazaret file

View File

@@ -13,7 +13,7 @@ namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Controller\RecordsRequest; use Alchemy\Phrasea\Controller\RecordsRequest;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCollectionChangedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCollectionChangedEvent;
use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use Silex\Application; use Silex\Application;
use Silex\ControllerProviderInterface; use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@@ -95,7 +95,7 @@ class MoveCollection implements ControllerProviderInterface
foreach ($records as $record) { foreach ($records as $record) {
$record->move_to_collection($collection, $app['phraseanet.appbox']); $record->move_to_collection($collection, $app['phraseanet.appbox']);
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_COLLECTION_CHANGED, new RecordCollectionChangedEvent($record)); $app['dispatcher']->dispatch(RecordEvents::COLLECTION_CHANGED, new RecordCollectionChangedEvent($record));
if ($request->request->get("chg_coll_son") == "1") { if ($request->request->get("chg_coll_son") == "1") {
foreach ($record->get_children() as $child) { foreach ($record->get_children() as $child) {
@@ -103,7 +103,7 @@ class MoveCollection implements ControllerProviderInterface
$child->move_to_collection($collection, $app['phraseanet.appbox']); $child->move_to_collection($collection, $app['phraseanet.appbox']);
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_COLLECTION_CHANGED, new RecordCollectionChangedEvent($child)); $app['dispatcher']->dispatch(RecordEvents::COLLECTION_CHANGED, new RecordCollectionChangedEvent($child));
} }
} }
} }

View File

@@ -12,8 +12,8 @@
namespace Alchemy\Phrasea\Controller\Prod; namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Controller\RecordsRequest; use Alchemy\Phrasea\Controller\RecordsRequest;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Silex\Application; use Silex\Application;
use Silex\ControllerProviderInterface; use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
@@ -177,7 +177,7 @@ class Property implements ControllerProviderInterface
foreach ($record->get_children() as $child) { foreach ($record->get_children() as $child) {
if (null !== $updatedStatus = $this->updateRecordStatus($child, $postStatus)) { if (null !== $updatedStatus = $this->updateRecordStatus($child, $postStatus)) {
$updated[$record->get_serialize_key()] = $updatedStatus; $updated[$record->get_serialize_key()] = $updatedStatus;
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_STATUS_CHANGED, new RecordStatusChangedEvent($record)); $app['dispatcher']->dispatch(RecordEvents::STATUS_CHANGED, new RecordStatusChangedEvent($record));
} }
} }
} }

View File

@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Controller\RecordsRequest; use Alchemy\Phrasea\Controller\RecordsRequest;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordDeletedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordDeletedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\StoryDeletedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\StoryDeletedEvent;
use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions; use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
@@ -181,7 +182,7 @@ class Records implements ControllerProviderInterface
if ($record->isStory()) { if ($record->isStory()) {
$app['dispatcher']->dispatch(PhraseaEvents::STORY_DELETED, new StoryDeletedEvent($record)); $app['dispatcher']->dispatch(PhraseaEvents::STORY_DELETED, new StoryDeletedEvent($record));
} else { } else {
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_DELETED, new RecordDeletedEvent($record)); $app['dispatcher']->dispatch(RecordEvents::DELETED, new RecordDeletedEvent($record));
} }
} catch (\Exception $e) { } catch (\Exception $e) {

View File

@@ -12,8 +12,8 @@
namespace Alchemy\Phrasea\Controller\Prod; namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Controller\RecordsRequest; use Alchemy\Phrasea\Controller\RecordsRequest;
use Alchemy\Phrasea\Core\Event\RecordOriginalNameChangedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordOriginalNameChangedEvent;
use Alchemy\Phrasea\Exception\RuntimeException; use Alchemy\Phrasea\Exception\RuntimeException;
use DataURI; use DataURI;
use PHPExiftool\Exception\ExceptionInterface as PHPExiftoolException; use PHPExiftool\Exception\ExceptionInterface as PHPExiftoolException;
@@ -152,7 +152,7 @@ class Tools implements ControllerProviderInterface
if ((int) $request->request->get('ccfilename') === 1) { if ((int) $request->request->get('ccfilename') === 1) {
$record->set_original_name($fileName); $record->set_original_name($fileName);
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_ORIGINAL_NAME_CHANGED, new RecordOriginalNameChangedEvent($record)); $app['dispatcher']->dispatch(RecordEvents::ORIGINAL_NAME_CHANGED, new RecordOriginalNameChangedEvent($record));
} }
unlink($tempoFile); unlink($tempoFile);
rmdir($tempoDir); rmdir($tempoDir);

View File

@@ -15,6 +15,7 @@ use Alchemy\Phrasea\Border\File;
use Alchemy\Phrasea\Border\Attribute\Status; use Alchemy\Phrasea\Border\Attribute\Status;
use Alchemy\Phrasea\Core\Event\LazaretEvent; use Alchemy\Phrasea\Core\Event\LazaretEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Core\PhraseaEvents;
use DataURI\Parser; use DataURI\Parser;
use DataURI\Exception\Exception as DataUriException; use DataURI\Exception\Exception as DataUriException;
@@ -209,7 +210,7 @@ class Upload implements ControllerProviderInterface
$element = 'record'; $element = 'record';
$message = $app->trans('The record was successfully created'); $message = $app->trans('The record was successfully created');
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_CREATED, new RecordCreatedEvent($elementCreated)); $app['dispatcher']->dispatch(RecordEvents::CREATED, new RecordCreatedEvent($elementCreated));
// try to create thumbnail from data URI // try to create thumbnail from data URI
if ('' !== $b64Image = $request->request->get('b64_image', '')) { if ('' !== $b64Image = $request->request->get('b64_image', '')) {

View File

@@ -12,7 +12,7 @@
namespace Alchemy\Phrasea\Controller\Thesaurus; namespace Alchemy\Phrasea\Controller\Thesaurus;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent;
use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\User;
use Silex\Application; use Silex\Application;
use Silex\ControllerProviderInterface; use Silex\ControllerProviderInterface;
@@ -1497,7 +1497,7 @@ class Xmlhttp implements ControllerProviderInterface
if (!$request->get('debug')) { if (!$request->get('debug')) {
$record->set_metadatas($metadatasd, true); $record->set_metadatas($metadatasd, true);
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_METADATA_CHANGED, new RecordMetadataChangedEvent($record)); $app['dispatcher']->dispatch(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($record));
$ret['nRecsUpdated']++; $ret['nRecsUpdated']++;
} }

View File

@@ -0,0 +1,26 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event\RecordEvent;
final class RecordEvents
{
const CREATED = 'record.created';
const DELETED = 'record.deleted';
// Change
const COLLECTION_CHANGED = 'record.collection_changed';
const METADATA_CHANGED = 'record.metadata_changed';
const ORIGINAL_NAME_CHANGED = 'record.original_name_changed';
const STATUS_CHANGED = 'record.status_changed';
// Sub-definitions
const SUB_DEFINITION_CREATED = 'record.sub_definition_created';
const SUB_DEFINITION_SUBSTITUTED = 'record.sub_definition_substituted';
}

View File

@@ -46,17 +46,6 @@ final class PhraseaEvents
const STORY_DELETED = 'story.deleted'; const STORY_DELETED = 'story.deleted';
const STORY_METADATA_CHANGED = 'story.metadata_changed'; const STORY_METADATA_CHANGED = 'story.metadata_changed';
// Record lifecycle
const RECORD_CREATED = 'record.created';
const RECORD_DELETED = 'record.deleted';
// Record change
const RECORD_COLLECTION_CHANGED = 'record.collection_changed';
const RECORD_METADATA_CHANGED = 'record.metadata_changed';
const RECORD_ORIGINAL_NAME_CHANGED = 'record.original_name_changed';
const RECORD_STATUS_CHANGED = 'record.status_changed';
// Record sub-definitions
const RECORD_SUB_DEFINITION_CREATED = 'record.sub_definition_created';
const RECORD_SUB_DEFINITION_SUBSTITUTED = 'record.sub_definition_substituted';
const DATABOX_UPDATE_FIELD = 'databox.update.field'; const DATABOX_UPDATE_FIELD = 'databox.update.field';
const DATABOX_DELETE_FIELD = 'databox.delete.field'; const DATABOX_DELETE_FIELD = 'databox.delete.field';

View File

@@ -13,7 +13,7 @@ namespace Alchemy\Phrasea\Media;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordSubDefinitionCreatedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordSubDefinitionCreatedEvent;
use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use MediaAlchemyst\Alchemyst; use MediaAlchemyst\Alchemyst;
use MediaAlchemyst\Specification\SpecificationInterface; use MediaAlchemyst\Specification\SpecificationInterface;
use MediaVorus\MediaVorus; use MediaVorus\MediaVorus;
@@ -75,7 +75,7 @@ class SubdefGenerator
$record->clearSubdefCache($subdefname); $record->clearSubdefCache($subdefname);
$this->app['dispatcher']->dispatch(PhraseaEvents::RECORD_SUB_DEFINITION_CREATED, new RecordSubDefinitionCreatedEvent($record, $subDefName)); $this->app['dispatcher']->dispatch(RecordEvents::SUB_DEFINITION_CREATED, new RecordSubDefinitionCreatedEvent($record, $subDefName));
} }
return $this; return $this;

View File

@@ -13,7 +13,7 @@ namespace Alchemy\Phrasea\Media;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMediaSubstitutedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMediaSubstitutedEvent;
use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use MediaAlchemyst\Alchemyst; use MediaAlchemyst\Alchemyst;
use MediaAlchemyst\Exception\ExceptionInterface as MediaAlchemystException; use MediaAlchemyst\Exception\ExceptionInterface as MediaAlchemystException;
use MediaVorus\Media\MediaInterface; use MediaVorus\Media\MediaInterface;
@@ -97,6 +97,6 @@ class SubdefSubstituer
$record->rebuild_subdefs(); $record->rebuild_subdefs();
} }
$this->dispatcher->dispatch(PhraseaEvents::RECORD_SUB_DEFINITION_SUBSTITUTED, new RecordMediaSubstitutedEvent($record)); $this->dispatcher->dispatch(RecordEvents::SUB_DEFINITION_SUBSTITUTED, new RecordMediaSubstitutedEvent($record));
} }
} }

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Metadata; namespace Alchemy\Phrasea\Metadata;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent;
use PHPExiftool\Driver\Metadata\Metadata; use PHPExiftool\Driver\Metadata\Metadata;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -103,7 +104,7 @@ class PhraseanetMetadataSetter
if (count($metas) > 0) { if (count($metas) > 0) {
$record->set_metadatas($metas, true); $record->set_metadatas($metas, true);
$this->dispatcher->dispatch(PhraseaEvents::RECORD_METADATA_CHANGED, new RecordMetadataChangedEvent($record)); $this->dispatcher->dispatch(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($record));
} }
} }
} }

View File

@@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\TaskManager\Job;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCollectionChangedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCollectionChangedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordDeletedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordDeletedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent;
use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\TaskManager\Editor\RecordMoverEditor; use Alchemy\Phrasea\TaskManager\Editor\RecordMoverEditor;
@@ -84,7 +85,7 @@ class RecordMoverJob extends AbstractJob
$coll = \collection::get_from_coll_id($app, $databox, $row['coll']); $coll = \collection::get_from_coll_id($app, $databox, $row['coll']);
$rec->move_to_collection($coll, $app['phraseanet.appbox']); $rec->move_to_collection($coll, $app['phraseanet.appbox']);
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_COLLECTION_CHANGED, new RecordCollectionChangedEvent($rec)); $app['dispatcher']->dispatch(RecordEvents::COLLECTION_CHANGED, new RecordCollectionChangedEvent($rec));
if ($logsql) { if ($logsql) {
$this->log('debug', sprintf("on sbas %s move rid %s to coll %s \n", $row['sbas_id'], $row['record_id'], $coll->get_coll_id())); $this->log('debug', sprintf("on sbas %s move rid %s to coll %s \n", $row['sbas_id'], $row['record_id'], $coll->get_coll_id()));
@@ -101,7 +102,7 @@ class RecordMoverJob extends AbstractJob
} }
$rec->set_binary_status(implode('', $status)); $rec->set_binary_status(implode('', $status));
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_STATUS_CHANGED, new RecordStatusChangedEvent($rec)); $app['dispatcher']->dispatch(RecordEvents::STATUS_CHANGED, new RecordStatusChangedEvent($rec));
if ($logsql) { if ($logsql) {
$this->log('debug', sprintf("on sbas %s set rid %s status to %s \n", $row['sbas_id'], $row['record_id'], $status)); $this->log('debug', sprintf("on sbas %s set rid %s status to %s \n", $row['sbas_id'], $row['record_id'], $status));
@@ -114,7 +115,7 @@ class RecordMoverJob extends AbstractJob
foreach ($rec->get_children() as $child) { foreach ($rec->get_children() as $child) {
$child->delete(); $child->delete();
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_DELETED, new RecordDeletedEvent($child)); $app['dispatcher']->dispatch(RecordEvents::DELETED, new RecordDeletedEvent($child));
if ($logsql) { if ($logsql) {
$this->log('debug', sprintf("on sbas %s delete (grp child) rid %s \n", $row['sbas_id'], $child->get_record_id())); $this->log('debug', sprintf("on sbas %s delete (grp child) rid %s \n", $row['sbas_id'], $child->get_record_id()));
@@ -122,7 +123,7 @@ class RecordMoverJob extends AbstractJob
} }
} }
$rec->delete(); $rec->delete();
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_DELETED, new RecordDeletedEvent($rec)); $app['dispatcher']->dispatch(RecordEvents::DELETED, new RecordDeletedEvent($rec));
if ($logsql) { if ($logsql) {
$this->log('debug', sprintf("on sbas %s delete rid %s \n", $row['sbas_id'], $rec->get_record_id())); $this->log('debug', sprintf("on sbas %s delete rid %s \n", $row['sbas_id'], $rec->get_record_id()));
} }

View File

@@ -11,7 +11,7 @@
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent;
use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class caption_field implements cache_cacheableInterface class caption_field implements cache_cacheableInterface
@@ -321,7 +321,7 @@ class caption_field implements cache_cacheableInterface
$record = $databox_field->get_databox()->get_record($row['record_id']); $record = $databox_field->get_databox()->get_record($row['record_id']);
$record->set_metadatas([]); $record->set_metadatas([]);
$dispatcher->dispatch(PhraseaEvents::RECORD_METADATA_CHANGED, new RecordMetadataChangedEvent($record)); $dispatcher->dispatch(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($record));
unset($record); unset($record);
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -375,7 +375,7 @@ class caption_field implements cache_cacheableInterface
$caption_field->delete(); $caption_field->delete();
$record->set_metadatas([]); $record->set_metadatas([]);
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_METADATA_CHANGED, new RecordMetadataChangedEvent($record)); $app['dispatcher']->dispatch(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($record));
unset($caption_field); unset($caption_field);
unset($record); unset($record);

View File

@@ -14,8 +14,8 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Alchemy\Phrasea\Command\Command; use Alchemy\Phrasea\Command\Command;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent; use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
class module_console_fieldsMerge extends Command class module_console_fieldsMerge extends Command
{ {
@@ -198,7 +198,7 @@ class module_console_fieldsMerge extends Command
]], true); ]], true);
} }
$this->getService('dispatcher')->dispatch(PhraseaEvents::RECORD_METADATA_CHANGED, new RecordMetadataChangedEvent($record)); $this->getService('dispatcher')->dispatch(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($record));
unset($record); unset($record);
} }