Story record emits proper record events

This commit is contained in:
Mathieu Darse
2015-01-27 16:49:23 +01:00
parent a1d6fc03b6
commit bc61536a41
7 changed files with 7 additions and 64 deletions

View File

@@ -14,8 +14,6 @@ namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Controller\RecordsRequest;
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\PhraseaEvents;
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
use Silex\Application;
use Silex\ControllerProviderInterface;
@@ -179,11 +177,7 @@ class Records implements ControllerProviderInterface
$deleted[] = $record->get_serialize_key();
$record->delete();
if ($record->isStory()) {
$app['dispatcher']->dispatch(PhraseaEvents::STORY_DELETED, new StoryDeletedEvent($record));
} else {
$app['dispatcher']->dispatch(RecordEvents::DELETED, new RecordDeletedEvent($record));
}
$app['dispatcher']->dispatch(RecordEvents::DELETED, new RecordDeletedEvent($record));
} catch (\Exception $e) {
}

View File

@@ -13,8 +13,8 @@ namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Controller\Exception as ControllerException;
use Alchemy\Phrasea\Controller\RecordsRequest;
use Alchemy\Phrasea\Core\Event\RecordEvent\StoryMetadataChangedEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent;
use Alchemy\Phrasea\Model\Entities\StoryWZ;
use Silex\Application;
use Silex\ControllerProviderInterface;
@@ -76,7 +76,7 @@ class Story implements ControllerProviderInterface
$Story->set_metadatas($metadatas)->rebuild_subdefs();
$app['dispatcher']->dispatch(PhraseaEvents::STORY_METADATA_CHANGED, new StoryMetadataChangedEvent($Story));
$app['dispatcher']->dispatch(RecordEvents::METADATA_CHANGED, new RecordMetadataChangedEvent($Story));
$StoryWZ = new StoryWZ();
$StoryWZ->setUser($app['authentication']->getUser());

View File

@@ -1,16 +0,0 @@
<?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 StoryCreatedEvent extends RecordEvent
{
}

View File

@@ -1,16 +0,0 @@
<?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 StoryDeletedEvent extends RecordEvent
{
}

View File

@@ -1,16 +0,0 @@
<?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
{
}

View File

@@ -42,9 +42,6 @@ final class PhraseaEvents
const EXPORT_MAIL_FAILURE = 'export.mail-failure';
const EXPORT_CREATE = 'export.create';
const STORY_CREATED = 'story.created';
const STORY_DELETED = 'story.deleted';
const STORY_METADATA_CHANGED = 'story.metadata_changed';
const DATABOX_UPDATE_FIELD = 'databox.update.field';

View File

@@ -12,8 +12,8 @@
namespace Alchemy\Phrasea\TaskManager\Job;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Event\RecordEvent\StoryCreatedEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent;
use Alchemy\Phrasea\Exception\RuntimeException;
use Alchemy\Phrasea\Border\File;
use Alchemy\Phrasea\TaskManager\Editor\ArchiveEditor;
@@ -1018,7 +1018,7 @@ class ArchiveJob extends AbstractJob
$story->set_binary_status(\databox_status::operation_or($app, $stat0, $stat1));
$story->rebuild_subdefs();
$app['dispatcher']->dispatch(PhraseaEvents::STORY_CREATED, new StoryCreatedEvent($story));
$app['dispatcher']->dispatch(RecordEvents::CREATED, new RecordCreatedEvent($story));
unset($media);