mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 13:33:14 +00:00
Centralize record event dispatches inside record adapter (but not structure ones)
This commit is contained in:
@@ -13,8 +13,6 @@ 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\Record\RecordEvents;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordStatusChangedEvent;
|
|
||||||
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,8 +288,6 @@ 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(RecordEvents::STATUS_CHANGED, new RecordStatusChangedEvent($element));
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case AttributeInterface::NAME_STORY:
|
case AttributeInterface::NAME_STORY:
|
||||||
|
|
||||||
|
@@ -13,8 +13,6 @@ 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\Record\RecordCreatedEvent;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\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 +115,6 @@ 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(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())
|
||||||
|
@@ -284,8 +284,7 @@ class Fields implements ControllerProviderInterface
|
|||||||
public function deleteField(Application $app, $sbas_id, $id)
|
public function deleteField(Application $app, $sbas_id, $id)
|
||||||
{
|
{
|
||||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||||
$field = \databox_field::get_instance($app, $databox, $id);
|
\databox_field::get_instance($app, $databox, $id)->delete();
|
||||||
$field->delete();
|
|
||||||
|
|
||||||
return new Response('', 204);
|
return new Response('', 204);
|
||||||
}
|
}
|
||||||
|
@@ -11,10 +11,6 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Controller\Api;
|
namespace Alchemy\Phrasea\Controller\Api;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordCreatedEvent;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordMetadataChangedEvent;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordStatusChangedEvent;
|
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Alchemy\Phrasea\Cache\Cache as CacheInterface;
|
use Alchemy\Phrasea\Cache\Cache as CacheInterface;
|
||||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||||
@@ -562,8 +558,6 @@ class V1 implements ControllerProviderInterface
|
|||||||
if ($output instanceof \record_adapter) {
|
if ($output instanceof \record_adapter) {
|
||||||
$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(RecordEvents::CREATED, new RecordCreatedEvent($output));
|
|
||||||
}
|
}
|
||||||
if ($output instanceof LazaretFile) {
|
if ($output instanceof LazaretFile) {
|
||||||
$ret['entity'] = '1';
|
$ret['entity'] = '1';
|
||||||
@@ -834,7 +828,6 @@ class V1 implements ControllerProviderInterface
|
|||||||
});
|
});
|
||||||
|
|
||||||
$record->set_metadatas($metadatas);
|
$record->set_metadatas($metadatas);
|
||||||
$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();
|
||||||
}
|
}
|
||||||
@@ -868,8 +861,6 @@ class V1 implements ControllerProviderInterface
|
|||||||
|
|
||||||
$record->set_binary_status(strrev($datas));
|
$record->set_binary_status(strrev($datas));
|
||||||
|
|
||||||
$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())];
|
||||||
|
|
||||||
return Result::create($request, $ret)->createResponse();
|
return Result::create($request, $ret)->createResponse();
|
||||||
|
@@ -11,9 +11,6 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Controller\Prod;
|
namespace Alchemy\Phrasea\Controller\Prod;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordMetadataChangedEvent;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordStatusChangedEvent;
|
|
||||||
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;
|
||||||
@@ -350,8 +347,6 @@ 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(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($record));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -377,8 +372,6 @@ class Edit implements ControllerProviderInterface
|
|||||||
];
|
];
|
||||||
|
|
||||||
$record->set_metadatas($metas, true);
|
$record->set_metadatas($metas, true);
|
||||||
|
|
||||||
$app['dispatcher']->dispatch(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($record));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$newstat = $record->get_status();
|
$newstat = $record->get_status();
|
||||||
@@ -396,8 +389,6 @@ class Edit implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$record->set_binary_status($newstat);
|
$record->set_binary_status($newstat);
|
||||||
|
|
||||||
$app['dispatcher']->dispatch(RecordEvents::STATUS_CHANGED, new RecordStatusChangedEvent($record));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$record
|
$record
|
||||||
|
@@ -11,10 +11,6 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Controller\Prod;
|
namespace Alchemy\Phrasea\Controller\Prod;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordCreatedEvent;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordMetadataChangedEvent;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordStatusChangedEvent;
|
|
||||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||||
use Alchemy\Phrasea\Model\Entities\LazaretFile;
|
use Alchemy\Phrasea\Model\Entities\LazaretFile;
|
||||||
use Alchemy\Phrasea\Border;
|
use Alchemy\Phrasea\Border;
|
||||||
@@ -200,8 +196,6 @@ class Lazaret implements ControllerProviderInterface
|
|||||||
$lazaretFile->getSession(), $borderFile, $callBack, Border\Manager::FORCE_RECORD
|
$lazaretFile->getSession(), $borderFile, $callBack, Border\Manager::FORCE_RECORD
|
||||||
);
|
);
|
||||||
|
|
||||||
$app['dispatcher']->dispatch(RecordEvents::CREATED, new RecordCreatedEvent($record));
|
|
||||||
|
|
||||||
if ($keepAttributes) {
|
if ($keepAttributes) {
|
||||||
//add attribute
|
//add attribute
|
||||||
|
|
||||||
@@ -234,8 +228,6 @@ class Lazaret implements ControllerProviderInterface
|
|||||||
break;
|
break;
|
||||||
case AttributeInterface::NAME_STATUS:
|
case AttributeInterface::NAME_STATUS:
|
||||||
$record->set_binary_status($attribute->getValue());
|
$record->set_binary_status($attribute->getValue());
|
||||||
|
|
||||||
$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,8 +240,6 @@ 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(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($record));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Delete lazaret file
|
//Delete lazaret file
|
||||||
|
@@ -12,8 +12,6 @@
|
|||||||
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\Record\RecordCollectionChangedEvent;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -95,15 +93,10 @@ 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(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) {
|
||||||
if ($app['acl']->get($app['authentication']->getUser())->has_right_on_base($child->get_base_id(), 'candeleterecord')) {
|
if ($app['acl']->get($app['authentication']->getUser())->has_right_on_base($child->get_base_id(), 'candeleterecord')) {
|
||||||
$child->move_to_collection($collection, $app['phraseanet.appbox']);
|
$child->move_to_collection($collection, $app['phraseanet.appbox']);
|
||||||
|
|
||||||
|
|
||||||
$app['dispatcher']->dispatch(RecordEvents::COLLECTION_CHANGED, new RecordCollectionChangedEvent($child));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,8 +12,6 @@
|
|||||||
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\Record\RecordEvents;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordStatusChangedEvent;
|
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
@@ -177,7 +175,6 @@ 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(RecordEvents::STATUS_CHANGED, new RecordStatusChangedEvent($record));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,8 +12,6 @@
|
|||||||
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\Record\RecordDeletedEvent;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
|
||||||
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
|
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
@@ -176,8 +174,6 @@ class Records implements ControllerProviderInterface
|
|||||||
|
|
||||||
$deleted[] = $record->get_serialize_key();
|
$deleted[] = $record->get_serialize_key();
|
||||||
$record->delete();
|
$record->delete();
|
||||||
|
|
||||||
$app['dispatcher']->dispatch(RecordEvents::DELETED, new RecordDeletedEvent($record));
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -13,8 +13,6 @@ 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\Record\RecordEvents;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordMetadataChangedEvent;
|
|
||||||
use Alchemy\Phrasea\Model\Entities\StoryWZ;
|
use Alchemy\Phrasea\Model\Entities\StoryWZ;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
@@ -76,8 +74,6 @@ class Story implements ControllerProviderInterface
|
|||||||
|
|
||||||
$Story->set_metadatas($metadatas)->rebuild_subdefs();
|
$Story->set_metadatas($metadatas)->rebuild_subdefs();
|
||||||
|
|
||||||
$app['dispatcher']->dispatch(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($Story));
|
|
||||||
|
|
||||||
$StoryWZ = new StoryWZ();
|
$StoryWZ = new StoryWZ();
|
||||||
$StoryWZ->setUser($app['authentication']->getUser());
|
$StoryWZ->setUser($app['authentication']->getUser());
|
||||||
$StoryWZ->setRecord($Story);
|
$StoryWZ->setRecord($Story);
|
||||||
|
@@ -12,8 +12,6 @@
|
|||||||
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\Record\RecordEvents;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\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;
|
||||||
@@ -151,8 +149,6 @@ 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(RecordEvents::ORIGINAL_NAME_CHANGED, new RecordOriginalNameChangedEvent($record));
|
|
||||||
}
|
}
|
||||||
unlink($tempoFile);
|
unlink($tempoFile);
|
||||||
rmdir($tempoDir);
|
rmdir($tempoDir);
|
||||||
|
@@ -14,8 +14,6 @@ namespace Alchemy\Phrasea\Controller\Prod;
|
|||||||
use Alchemy\Phrasea\Border\File;
|
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\Record\RecordCreatedEvent;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\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;
|
||||||
@@ -210,8 +208,6 @@ 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(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', '')) {
|
||||||
try {
|
try {
|
||||||
|
@@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Controller\Thesaurus;
|
namespace Alchemy\Phrasea\Controller\Thesaurus;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordMetadataChangedEvent;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\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;
|
||||||
@@ -1496,9 +1494,6 @@ class Xmlhttp implements ControllerProviderInterface
|
|||||||
if (count($metadatasd) > 0) {
|
if (count($metadatasd) > 0) {
|
||||||
if (!$request->get('debug')) {
|
if (!$request->get('debug')) {
|
||||||
$record->set_metadatas($metadatasd, true);
|
$record->set_metadatas($metadatasd, true);
|
||||||
|
|
||||||
$app['dispatcher']->dispatch(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($record));
|
|
||||||
|
|
||||||
$ret['nRecsUpdated']++;
|
$ret['nRecsUpdated']++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -69,7 +69,7 @@ class PhraseanetServiceProvider implements ServiceProviderInterface
|
|||||||
});
|
});
|
||||||
|
|
||||||
$app['phraseanet.metadata-setter'] = $app->share(function (SilexApplication $app) {
|
$app['phraseanet.metadata-setter'] = $app->share(function (SilexApplication $app) {
|
||||||
return new PhraseanetMetadataSetter($app['dispatcher']);
|
return new PhraseanetMetadataSetter();
|
||||||
});
|
});
|
||||||
|
|
||||||
$app['phraseanet.user-query'] = function (SilexApplication $app) {
|
$app['phraseanet.user-query'] = function (SilexApplication $app) {
|
||||||
|
@@ -11,20 +11,10 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Metadata;
|
namespace Alchemy\Phrasea\Metadata;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordMetadataChangedEvent;
|
|
||||||
use PHPExiftool\Driver\Metadata\Metadata;
|
use PHPExiftool\Driver\Metadata\Metadata;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
||||||
|
|
||||||
class PhraseanetMetadataSetter
|
class PhraseanetMetadataSetter
|
||||||
{
|
{
|
||||||
private $dispatcher;
|
|
||||||
|
|
||||||
public function __construct(EventDispatcherInterface $dispatcher)
|
|
||||||
{
|
|
||||||
$this->dispatcher = $dispatcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function replaceMetadata($metadataCollection, \record_adapter $record)
|
public function replaceMetadata($metadataCollection, \record_adapter $record)
|
||||||
{
|
{
|
||||||
$metadatas = [];
|
$metadatas = [];
|
||||||
@@ -103,8 +93,6 @@ class PhraseanetMetadataSetter
|
|||||||
|
|
||||||
if (count($metas) > 0) {
|
if (count($metas) > 0) {
|
||||||
$record->set_metadatas($metas, true);
|
$record->set_metadatas($metas, true);
|
||||||
|
|
||||||
$this->dispatcher->dispatch(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($record));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,8 +12,6 @@
|
|||||||
namespace Alchemy\Phrasea\TaskManager\Job;
|
namespace Alchemy\Phrasea\TaskManager\Job;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordCreatedEvent;
|
|
||||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||||
use Alchemy\Phrasea\Border\File;
|
use Alchemy\Phrasea\Border\File;
|
||||||
use Alchemy\Phrasea\TaskManager\Editor\ArchiveEditor;
|
use Alchemy\Phrasea\TaskManager\Editor\ArchiveEditor;
|
||||||
@@ -1018,8 +1016,6 @@ class ArchiveJob extends AbstractJob
|
|||||||
$story->set_binary_status(\databox_status::operation_or($app, $stat0, $stat1));
|
$story->set_binary_status(\databox_status::operation_or($app, $stat0, $stat1));
|
||||||
$story->rebuild_subdefs();
|
$story->rebuild_subdefs();
|
||||||
|
|
||||||
$app['dispatcher']->dispatch(RecordEvents::CREATED, new RecordCreatedEvent($story));
|
|
||||||
|
|
||||||
unset($media);
|
unset($media);
|
||||||
|
|
||||||
return $story;
|
return $story;
|
||||||
|
@@ -12,13 +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\Record\RecordCollectionChangedEvent;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordDeletedEvent;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordStatusChangedEvent;
|
|
||||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
|
||||||
use Alchemy\Phrasea\TaskManager\Editor\RecordMoverEditor;
|
use Alchemy\Phrasea\TaskManager\Editor\RecordMoverEditor;
|
||||||
use JMS\Serializer\EventDispatcher\EventDispatcher;
|
|
||||||
|
|
||||||
class RecordMoverJob extends AbstractJob
|
class RecordMoverJob extends AbstractJob
|
||||||
{
|
{
|
||||||
@@ -84,9 +78,6 @@ class RecordMoverJob extends AbstractJob
|
|||||||
if (array_key_exists('coll', $row)) {
|
if (array_key_exists('coll', $row)) {
|
||||||
$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(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,9 +92,6 @@ class RecordMoverJob extends AbstractJob
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$rec->set_binary_status(implode('', $status));
|
$rec->set_binary_status(implode('', $status));
|
||||||
|
|
||||||
$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,16 +102,12 @@ class RecordMoverJob extends AbstractJob
|
|||||||
if ($row['deletechildren'] && $rec->is_grouping()) {
|
if ($row['deletechildren'] && $rec->is_grouping()) {
|
||||||
foreach ($rec->get_children() as $child) {
|
foreach ($rec->get_children() as $child) {
|
||||||
$child->delete();
|
$child->delete();
|
||||||
|
|
||||||
$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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$rec->delete();
|
$rec->delete();
|
||||||
$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()));
|
||||||
}
|
}
|
||||||
|
@@ -10,9 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordMetadataChangedEvent;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
||||||
|
|
||||||
class caption_field implements cache_cacheableInterface
|
class caption_field implements cache_cacheableInterface
|
||||||
{
|
{
|
||||||
@@ -285,7 +282,7 @@ class caption_field implements cache_cacheableInterface
|
|||||||
return $values;
|
return $values;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function rename_all_metadata(EventDispatcherInterface $dispatcher, databox_field $databox_field)
|
public static function rename_all_metadatas(databox_field $databox_field)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT count(id) as count_id FROM metadatas
|
$sql = 'SELECT count(id) as count_id FROM metadatas
|
||||||
WHERE meta_struct_id = :meta_struct_id';
|
WHERE meta_struct_id = :meta_struct_id';
|
||||||
@@ -321,8 +318,6 @@ 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(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($record));
|
|
||||||
|
|
||||||
unset($record);
|
unset($record);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
@@ -375,8 +370,6 @@ class caption_field implements cache_cacheableInterface
|
|||||||
$caption_field->delete();
|
$caption_field->delete();
|
||||||
$record->set_metadatas([]);
|
$record->set_metadatas([]);
|
||||||
|
|
||||||
$app['dispatcher']->dispatch(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($record));
|
|
||||||
|
|
||||||
unset($caption_field);
|
unset($caption_field);
|
||||||
unset($record);
|
unset($record);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@@ -428,7 +428,7 @@ class databox_field implements cache_cacheableInterface
|
|||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if ($this->renamed) {
|
if ($this->renamed) {
|
||||||
caption_field::rename_all_metadata($this->app['dispatcher'], $this);
|
caption_field::rename_all_metadatas($this);
|
||||||
$this->renamed = false;
|
$this->renamed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,8 +14,6 @@ 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\Record\RecordEvents;
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordMetadataChangedEvent;
|
|
||||||
|
|
||||||
class module_console_fieldsMerge extends Command
|
class module_console_fieldsMerge extends Command
|
||||||
{
|
{
|
||||||
@@ -198,8 +196,6 @@ class module_console_fieldsMerge extends Command
|
|||||||
]], true);
|
]], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getService('dispatcher')->dispatch(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($record));
|
|
||||||
|
|
||||||
unset($record);
|
unset($record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11,6 +11,14 @@
|
|||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Alchemy\Phrasea\Border\File;
|
use Alchemy\Phrasea\Border\File;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\RecordEvent;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\RecordCollectionChangedEvent;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\RecordCreatedEvent;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\RecordDeletedEvent;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\RecordMetadataChangedEvent;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\RecordOriginalNameChangedEvent;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\RecordStatusChangedEvent;
|
||||||
use Alchemy\Phrasea\Metadata\Tag\TfFilename;
|
use Alchemy\Phrasea\Metadata\Tag\TfFilename;
|
||||||
use Alchemy\Phrasea\Metadata\Tag\TfBasename;
|
use Alchemy\Phrasea\Metadata\Tag\TfBasename;
|
||||||
use Alchemy\Phrasea\Model\Entities\User;
|
use Alchemy\Phrasea\Model\Entities\User;
|
||||||
@@ -492,6 +500,8 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
|
|
||||||
$this->delete_data_from_cache();
|
$this->delete_data_from_cache();
|
||||||
|
|
||||||
|
$this->dispatch(RecordEvents::COLLECTION_CHANGED, new RecordCollectionChangedEvent($this));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -854,6 +864,8 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
|
|
||||||
$this->delete_data_from_cache();
|
$this->delete_data_from_cache();
|
||||||
|
|
||||||
|
$this->dispatch(RecordEvents::ORIGINAL_NAME_CHANGED, new RecordOriginalNameChangedEvent($this));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1066,6 +1078,8 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
$this->set_xml($xml);
|
$this->set_xml($xml);
|
||||||
unset($xml);
|
unset($xml);
|
||||||
|
|
||||||
|
$this->dispatch(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($this));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1135,9 +1149,16 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
|
|
||||||
$this->delete_data_from_cache(self::CACHE_STATUS);
|
$this->delete_data_from_cache(self::CACHE_STATUS);
|
||||||
|
|
||||||
|
$this->dispatch(RecordEvents::STATUS_CHANGED, new RecordStatusChangedEvent($this));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function dispatch($eventName, RecordEvent $event)
|
||||||
|
{
|
||||||
|
$this->app['dispatcher']->dispatch($eventName, $event);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param Application $app
|
* @param Application $app
|
||||||
@@ -1191,6 +1212,8 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
unset($e);
|
unset($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->dispatchCreatedEvent()
|
||||||
|
|
||||||
return $story;
|
return $story;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1260,9 +1283,16 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
$record->insertTechnicalDatas($app['mediavorus']);
|
$record->insertTechnicalDatas($app['mediavorus']);
|
||||||
$record->rebuild_subdefs();
|
$record->rebuild_subdefs();
|
||||||
|
|
||||||
|
$this->dispatchCreatedEvent()
|
||||||
|
|
||||||
return $record;
|
return $record;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function dispatchCreatedEvent()
|
||||||
|
{
|
||||||
|
$this->dispatch(RecordEvents::CREATED, new RecordCreatedEvent($this));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read technical datas an insert them
|
* Read technical datas an insert them
|
||||||
* This method can be long to perform
|
* This method can be long to perform
|
||||||
@@ -1508,6 +1538,8 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
|
|
||||||
$this->delete_data_from_cache(self::CACHE_SUBDEFS);
|
$this->delete_data_from_cache(self::CACHE_SUBDEFS);
|
||||||
|
|
||||||
|
$this->dispatch(RecordEvents::DELETED, new RecordDeletedEvent($record));
|
||||||
|
|
||||||
return array_keys($ftodel);
|
return array_keys($ftodel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user