mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Record create/delete events OK
This commit is contained in:
@@ -13,7 +13,7 @@ namespace Alchemy\Phrasea\Command;
|
||||
|
||||
use Alchemy\Phrasea\Border\File;
|
||||
use Alchemy\Phrasea\Border\Manager;
|
||||
use Alchemy\Phrasea\Core\Event\RecordEvent\CreateRecordEvent;
|
||||
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent;
|
||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||
use Alchemy\Phrasea\Model\Entities\LazaretFile;
|
||||
use Alchemy\Phrasea\Model\Entities\LazaretSession;
|
||||
@@ -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'])
|
||||
)
|
||||
);
|
||||
$this->container['dispatcher']->dispatch(PhraseaEvents::RECORD_CREATE, new CreateRecordEvent($elementCreated));
|
||||
$this->container['dispatcher']->dispatch(PhraseaEvents::RECORD_CREATED, new RecordCreatedEvent($elementCreated));
|
||||
} elseif ($elementCreated instanceof LazaretFile) {
|
||||
$output->writeln(
|
||||
sprintf("Quarantine item id <info>%d</info> has been created", $elementCreated->getId())
|
||||
|
@@ -13,7 +13,7 @@ namespace Alchemy\Phrasea\Controller\Api;
|
||||
|
||||
use Alchemy\Phrasea\Core\Event\ChangeStatusEvent;
|
||||
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeMetadataEvent;
|
||||
use Alchemy\Phrasea\Core\Event\RecordEvent\CreateRecordEvent;
|
||||
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Alchemy\Phrasea\Cache\Cache as CacheInterface;
|
||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||
@@ -562,7 +562,7 @@ class V1 implements ControllerProviderInterface
|
||||
$ret['entity'] = '0';
|
||||
$ret['url'] = '/records/' . $output->get_sbas_id() . '/' . $output->get_record_id() . '/';
|
||||
|
||||
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_CREATE, new CreateRecordEvent($output));
|
||||
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_CREATED, new RecordCreatedEvent($output));
|
||||
}
|
||||
if ($output instanceof LazaretFile) {
|
||||
$ret['entity'] = '1';
|
||||
|
@@ -13,7 +13,7 @@ namespace Alchemy\Phrasea\Controller\Prod;
|
||||
|
||||
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeMetadataEvent;
|
||||
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeStatusEvent;
|
||||
use Alchemy\Phrasea\Core\Event\RecordEvent\CreateRecordEvent;
|
||||
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent;
|
||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||
use Alchemy\Phrasea\Model\Entities\LazaretFile;
|
||||
use Alchemy\Phrasea\Border;
|
||||
@@ -199,7 +199,7 @@ class Lazaret implements ControllerProviderInterface
|
||||
$lazaretFile->getSession(), $borderFile, $callBack, Border\Manager::FORCE_RECORD
|
||||
);
|
||||
|
||||
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_CREATE, new CreateRecordEvent($record));
|
||||
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_CREATED, new RecordCreatedEvent($record));
|
||||
|
||||
if ($keepAttributes) {
|
||||
//add attribute
|
||||
|
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Controller\Prod;
|
||||
|
||||
use Alchemy\Phrasea\Controller\RecordsRequest;
|
||||
use Alchemy\Phrasea\Core\Event\RecordEvent\DeleteStoryEvent;
|
||||
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordDeletedEvent;
|
||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
|
||||
use Silex\Application;
|
||||
@@ -180,7 +181,7 @@ class Records implements ControllerProviderInterface
|
||||
if ($record->isStory()) {
|
||||
$app['dispatcher']->dispatch(PhraseaEvents::STORY_DELETE, new DeleteStoryEvent($record));
|
||||
} else {
|
||||
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_DELETE, new DeleteRecordEvent($record));
|
||||
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_DELETED, new RecordDeletedEvent($record));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
|
||||
|
@@ -14,7 +14,7 @@ namespace Alchemy\Phrasea\Controller\Prod;
|
||||
use Alchemy\Phrasea\Border\File;
|
||||
use Alchemy\Phrasea\Border\Attribute\Status;
|
||||
use Alchemy\Phrasea\Core\Event\LazaretEvent;
|
||||
use Alchemy\Phrasea\Core\Event\RecordEvent\CreateRecordEvent;
|
||||
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent;
|
||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||
use DataURI\Parser;
|
||||
use DataURI\Exception\Exception as DataUriException;
|
||||
@@ -209,7 +209,7 @@ class Upload implements ControllerProviderInterface
|
||||
$element = 'record';
|
||||
$message = $app->trans('The record was successfully created');
|
||||
|
||||
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_CREATE, new CreateRecordEvent($elementCreated));
|
||||
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_CREATED, new RecordCreatedEvent($elementCreated));
|
||||
|
||||
// try to create thumbnail from data URI
|
||||
if ('' !== $b64Image = $request->request->get('b64_image', '')) {
|
||||
|
@@ -11,10 +11,5 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Event\RecordEvent;
|
||||
|
||||
use Alchemy\Phrasea\Model\Entities\Basket;
|
||||
use Symfony\Component\EventDispatcher\Event as SfEvent;
|
||||
|
||||
class CreateRecordEvent extends RecordEvent
|
||||
{
|
||||
|
||||
}
|
||||
class RecordCreatedEvent extends RecordEvent
|
||||
{}
|
@@ -11,9 +11,6 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Event\RecordEvent;
|
||||
|
||||
use Alchemy\Phrasea\Model\Entities\Basket;
|
||||
use Symfony\Component\EventDispatcher\Event as SfEvent;
|
||||
|
||||
class DeleteRecordEvent extends RecordEvent
|
||||
class RecordDeletedEvent extends RecordEvent
|
||||
{
|
||||
}
|
@@ -11,17 +11,18 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Event\RecordEvent;
|
||||
|
||||
use Symfony\Component\EventDispatcher\Event as SfEvent;
|
||||
use Alchemy\Phrasea\Model\RecordInterface;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
|
||||
class RecordEvent extends SfEvent
|
||||
abstract class RecordEvent extends Event
|
||||
{
|
||||
public function __construct(\record_adapter $record)
|
||||
public function __construct(RecordInterface $record)
|
||||
{
|
||||
$this->record = $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \record_adapter
|
||||
* @return RecordInterface
|
||||
*/
|
||||
public function getRecord()
|
||||
{
|
||||
|
@@ -42,8 +42,8 @@ final class PhraseaEvents
|
||||
const EXPORT_MAIL_FAILURE = 'export.mail-failure';
|
||||
const EXPORT_CREATE = 'export.create';
|
||||
|
||||
const RECORD_CREATE = 'record.create';
|
||||
const RECORD_DELETE = 'record.delete';
|
||||
const RECORD_CREATED = 'record.created';
|
||||
const RECORD_DELETED = 'record.deleted';
|
||||
const STORY_CREATE = 'story.create';
|
||||
const STORY_DELETE = 'story.delete';
|
||||
const RECORD_CHANGE_COLLECTION = 'record.collection';
|
||||
|
@@ -14,7 +14,7 @@ namespace Alchemy\Phrasea\TaskManager\Job;
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeCollectionEvent;
|
||||
use Alchemy\Phrasea\Core\Event\RecordEvent\ChangeStatusEvent;
|
||||
use Alchemy\Phrasea\Core\Event\RecordEvent\DeleteRecordEvent;
|
||||
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordDeletedEvent;
|
||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||
use Alchemy\Phrasea\TaskManager\Editor\RecordMoverEditor;
|
||||
use JMS\Serializer\EventDispatcher\EventDispatcher;
|
||||
@@ -114,7 +114,7 @@ class RecordMoverJob extends AbstractJob
|
||||
foreach ($rec->get_children() as $child) {
|
||||
$child->delete();
|
||||
|
||||
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_DELETE, new DeleteRecordEvent($child));
|
||||
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_DELETED, new RecordDeletedEvent($child));
|
||||
|
||||
if ($logsql) {
|
||||
$this->log('debug', sprintf("on sbas %s delete (grp child) rid %s \n", $row['sbas_id'], $child->get_record_id()));
|
||||
@@ -122,7 +122,7 @@ class RecordMoverJob extends AbstractJob
|
||||
}
|
||||
}
|
||||
$rec->delete();
|
||||
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_DELETE, new DeleteRecordEvent($rec));
|
||||
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_DELETED, new RecordDeletedEvent($rec));
|
||||
if ($logsql) {
|
||||
$this->log('debug', sprintf("on sbas %s delete rid %s \n", $row['sbas_id'], $rec->get_record_id()));
|
||||
}
|
||||
|
Reference in New Issue
Block a user