mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 20:43:25 +00:00
Record/story metadata and collection change events OK
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
namespace Alchemy\Phrasea\Controller\Api;
|
namespace Alchemy\Phrasea\Controller\Api;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Event\ChangeStatusEvent;
|
use Alchemy\Phrasea\Core\Event\ChangeStatusEvent;
|
||||||
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeMetadataEvent;
|
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent;
|
||||||
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent;
|
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Alchemy\Phrasea\Cache\Cache as CacheInterface;
|
use Alchemy\Phrasea\Cache\Cache as CacheInterface;
|
||||||
@@ -833,7 +833,7 @@ class V1 implements ControllerProviderInterface
|
|||||||
});
|
});
|
||||||
|
|
||||||
$record->set_metadatas($metadatas);
|
$record->set_metadatas($metadatas);
|
||||||
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_CHANGE_METADATA, new ChangeMetadataEvent($record));
|
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_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();
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Controller\Prod;
|
namespace Alchemy\Phrasea\Controller\Prod;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeMetadataEvent;
|
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent;
|
||||||
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeStatusEvent;
|
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeStatusEvent;
|
||||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||||
use Alchemy\Phrasea\Vocabulary\Controller as VocabularyController;
|
use Alchemy\Phrasea\Vocabulary\Controller as VocabularyController;
|
||||||
@@ -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_CHANGE_METADATA, new ChangeMetadataEvent($record));
|
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_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_CHANGE_METADATA, new ChangeMetadataEvent($record));
|
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_METADATA_CHANGED, new RecordMetadataChangedEvent($record));
|
||||||
}
|
}
|
||||||
|
|
||||||
$newstat = $record->get_status();
|
$newstat = $record->get_status();
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Controller\Prod;
|
namespace Alchemy\Phrasea\Controller\Prod;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeMetadataEvent;
|
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent;
|
||||||
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeStatusEvent;
|
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeStatusEvent;
|
||||||
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent;
|
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent;
|
||||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||||
@@ -248,7 +248,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_CHANGE_METADATA, new ChangeMetadataEvent($record));
|
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_METADATA_CHANGED, new RecordMetadataChangedEvent($record));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Delete lazaret file
|
//Delete lazaret file
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
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\ChangeCollectionEvent;
|
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCollectionChangedEvent;
|
||||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
@@ -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_CHANGE_COLLECTION, new ChangeCollectionEvent($record));
|
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_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_CHANGE_COLLECTION, new ChangeCollectionEvent($child));
|
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_COLLECTION_CHANGED, new RecordCollectionChangedEvent($child));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,7 @@ namespace Alchemy\Phrasea\Controller\Prod;
|
|||||||
|
|
||||||
use Alchemy\Phrasea\Controller\Exception as ControllerException;
|
use Alchemy\Phrasea\Controller\Exception as ControllerException;
|
||||||
use Alchemy\Phrasea\Controller\RecordsRequest;
|
use Alchemy\Phrasea\Controller\RecordsRequest;
|
||||||
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeMetadataEvent;
|
use Alchemy\Phrasea\Core\Event\RecordEvent\StoryMetadataChangedEvent;
|
||||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||||
use Alchemy\Phrasea\Model\Entities\StoryWZ;
|
use Alchemy\Phrasea\Model\Entities\StoryWZ;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
@@ -76,7 +76,7 @@ class Story implements ControllerProviderInterface
|
|||||||
|
|
||||||
$Story->set_metadatas($metadatas)->rebuild_subdefs();
|
$Story->set_metadatas($metadatas)->rebuild_subdefs();
|
||||||
|
|
||||||
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_CHANGE_METADATA, new ChangeMetadataEvent($Story));
|
$app['dispatcher']->dispatch(PhraseaEvents::STORY_METADATA_CHANGED, new StoryMetadataChangedEvent($Story));
|
||||||
|
|
||||||
$StoryWZ = new StoryWZ();
|
$StoryWZ = new StoryWZ();
|
||||||
$StoryWZ->setUser($app['authentication']->getUser());
|
$StoryWZ->setUser($app['authentication']->getUser());
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Controller\Thesaurus;
|
namespace Alchemy\Phrasea\Controller\Thesaurus;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeMetadataEvent;
|
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent;
|
||||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||||
use Alchemy\Phrasea\Model\Entities\User;
|
use Alchemy\Phrasea\Model\Entities\User;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
@@ -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_CHANGE_METADATA, new ChangeMetadataEvent($record));
|
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_METADATA_CHANGED, new RecordMetadataChangedEvent($record));
|
||||||
|
|
||||||
$ret['nRecsUpdated']++;
|
$ret['nRecsUpdated']++;
|
||||||
}
|
}
|
||||||
|
@@ -11,9 +11,6 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Core\Event\RecordEvent;
|
namespace Alchemy\Phrasea\Core\Event\RecordEvent;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Model\Entities\Basket;
|
class RecordCollectionChangedEvent extends RecordEvent
|
||||||
use Symfony\Component\EventDispatcher\Event as SfEvent;
|
|
||||||
|
|
||||||
class ChangeMetadataEvent extends RecordEvent
|
|
||||||
{
|
{
|
||||||
}
|
}
|
@@ -11,9 +11,6 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Core\Event\RecordEvent;
|
namespace Alchemy\Phrasea\Core\Event\RecordEvent;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Model\Entities\Basket;
|
class RecordMetadataChangedEvent extends RecordEvent
|
||||||
use Symfony\Component\EventDispatcher\Event as SfEvent;
|
|
||||||
|
|
||||||
class ChangeCollectionEvent extends RecordEvent
|
|
||||||
{
|
{
|
||||||
}
|
}
|
@@ -0,0 +1,16 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
class StoryMetadataChangedEvent extends RecordEvent
|
||||||
|
{
|
||||||
|
}
|
@@ -44,11 +44,14 @@ final class PhraseaEvents
|
|||||||
|
|
||||||
const STORY_CREATED = 'story.created';
|
const STORY_CREATED = 'story.created';
|
||||||
const STORY_DELETED = 'story.deleted';
|
const STORY_DELETED = 'story.deleted';
|
||||||
|
const STORY_METADATA_CHANGED = 'story.metadata_changed';
|
||||||
|
|
||||||
|
// Record lifecycle
|
||||||
const RECORD_CREATED = 'record.created';
|
const RECORD_CREATED = 'record.created';
|
||||||
const RECORD_DELETED = 'record.deleted';
|
const RECORD_DELETED = 'record.deleted';
|
||||||
const RECORD_CHANGE_COLLECTION = 'record.collection';
|
// Record change
|
||||||
const RECORD_CHANGE_METADATA = 'record.metadata';
|
const RECORD_COLLECTION_CHANGED = 'record.collection_changed';
|
||||||
|
const RECORD_METADATA_CHANGED = 'record.metadata_changed';
|
||||||
const RECORD_CHANGE_ORIGINAL_NAME = 'record.original_name';
|
const RECORD_CHANGE_ORIGINAL_NAME = 'record.original_name';
|
||||||
const RECORD_CHANGE_STATUS = 'record.status';
|
const RECORD_CHANGE_STATUS = 'record.status';
|
||||||
const RECORD_BUILD_SUB_DEFINITION = 'record.sub_definition';
|
const RECORD_BUILD_SUB_DEFINITION = 'record.sub_definition';
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Metadata;
|
namespace Alchemy\Phrasea\Metadata;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ class PhraseanetMetadataSetter
|
|||||||
|
|
||||||
public function __construct(EventDispatcherInterface $dispatcher)
|
public function __construct(EventDispatcherInterface $dispatcher)
|
||||||
{
|
{
|
||||||
$this->disptatcher = $dispatcher;
|
$this->dispatcher = $dispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function replaceMetadata($metadataCollection, \record_adapter $record)
|
public function replaceMetadata($metadataCollection, \record_adapter $record)
|
||||||
@@ -102,7 +103,7 @@ class PhraseanetMetadataSetter
|
|||||||
if (count($metas) > 0) {
|
if (count($metas) > 0) {
|
||||||
$record->set_metadatas($metas, true);
|
$record->set_metadatas($metas, true);
|
||||||
|
|
||||||
$this->disptatcher->dispatch(PhraseaEvents::RECORD_CHANGE_METADATA, new ChangeMetadataEvent($record));
|
$this->dispatcher->dispatch(PhraseaEvents::RECORD_METADATA_CHANGED, new RecordMetadataChangedEvent($record));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
namespace Alchemy\Phrasea\TaskManager\Job;
|
namespace Alchemy\Phrasea\TaskManager\Job;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeCollectionEvent;
|
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCollectionChangedEvent;
|
||||||
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeStatusEvent;
|
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeStatusEvent;
|
||||||
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordDeletedEvent;
|
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordDeletedEvent;
|
||||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||||
@@ -84,7 +84,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_CHANGE_COLLECTION, new ChangeCollectionEvent($rec));
|
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_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()));
|
||||||
|
@@ -10,8 +10,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent;
|
||||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||||
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeMetadataEvent;
|
|
||||||
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_CHANGE_METADATA, new ChangeMetadataEvent($record));
|
$dispatcher->dispatch(PhraseaEvents::RECORD_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_CHANGE_METADATA, new ChangeMetadataEvent($record));
|
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_METADATA_CHANGED, new RecordMetadataChangedEvent($record));
|
||||||
|
|
||||||
unset($caption_field);
|
unset($caption_field);
|
||||||
unset($record);
|
unset($record);
|
||||||
|
@@ -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\RecordMetadataChangedEvent;
|
||||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||||
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeMetadataEvent;
|
|
||||||
|
|
||||||
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_CHANGE_METADATA, new ChangeMetadataEvent($record));
|
$this->getService('dispatcher')->dispatch(PhraseaEvents::RECORD_METADATA_CHANGED, new RecordMetadataChangedEvent($record));
|
||||||
|
|
||||||
unset($record);
|
unset($record);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user