Merge record and structure events inside new namespace

This commit is contained in:
Mathieu Darse
2015-01-27 18:58:09 +01:00
parent bc61536a41
commit e287ba1a42
45 changed files with 172 additions and 177 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\Record\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent; 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;

View File

@@ -13,8 +13,8 @@ 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\Record\RecordCreatedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents; 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;

View File

@@ -11,9 +11,6 @@
namespace Alchemy\Phrasea\Controller\Admin; namespace Alchemy\Phrasea\Controller\Admin;
use Alchemy\Phrasea\Core\Event\DataboxEvent\UpdateStructureFieldEvent;
use Alchemy\Phrasea\Core\Event\DataboxEvent\DeleteStructureFieldEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Metadata\TagProvider; use Alchemy\Phrasea\Metadata\TagProvider;
use Alchemy\Phrasea\Vocabulary\Controller as VocabularyController; use Alchemy\Phrasea\Vocabulary\Controller as VocabularyController;
use JMS\TranslationBundle\Annotation\Ignore; use JMS\TranslationBundle\Annotation\Ignore;
@@ -117,8 +114,6 @@ class Fields implements ControllerProviderInterface
$this->updateFieldWithData($app, $field, $jsonField); $this->updateFieldWithData($app, $field, $jsonField);
$field->save(); $field->save();
$fields[] = $field->toArray(); $fields[] = $field->toArray();
$app['dispatcher']->dispatch(PhraseaEvents::DATABOX_UPDATE_FIELD, new UpdateStructureFieldEvent($field, $jsonField));
} catch (\Exception $e) { } catch (\Exception $e) {
$connection->rollback(); $connection->rollback();
$app->abort(500, $app->trans('Field %name% could not be saved, please try again or contact an admin.', ['%name%' => $jsonField['name']])); $app->abort(500, $app->trans('Field %name% could not be saved, please try again or contact an admin.', ['%name%' => $jsonField['name']]));
@@ -283,8 +278,6 @@ class Fields implements ControllerProviderInterface
$this->updateFieldWithData($app, $field, $data); $this->updateFieldWithData($app, $field, $data);
$field->save(); $field->save();
$app['dispatcher']->dispatch(PhraseaEvents::DATABOX_UPDATE_FIELD, new UpdateStructureFieldEvent($databox, $field, $jsonField));
return $app->json($field->toArray()); return $app->json($field->toArray());
} }
@@ -294,8 +287,6 @@ class Fields implements ControllerProviderInterface
$field = \databox_field::get_instance($app, $databox, $id); $field = \databox_field::get_instance($app, $databox, $id);
$field->delete(); $field->delete();
$app['dispatcher']->dispatch(PhraseaEvents::DATABOX_DELETE_FIELD, new DeleteStructureFieldEvent($databox, $field));
return new Response('', 204); return new Response('', 204);
} }
@@ -331,7 +322,6 @@ class Fields implements ControllerProviderInterface
private function updateFieldWithData(Application $app, \databox_field $field, array $data) private function updateFieldWithData(Application $app, \databox_field $field, array $data)
{ {
$field $field
->set_name($data['name']) ->set_name($data['name'])
->set_thumbtitle($data['thumbtitle']) ->set_thumbtitle($data['thumbtitle'])

View File

@@ -11,9 +11,6 @@
namespace Alchemy\Phrasea\Controller\Admin; namespace Alchemy\Phrasea\Controller\Admin;
use Alchemy\Phrasea\Core\Event\DataboxEvent\DeleteStatusEvent;
use Alchemy\Phrasea\Core\Event\DataboxEvent\UpdateStatusEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Exception\SessionNotFound; use Alchemy\Phrasea\Exception\SessionNotFound;
use Alchemy\Phrasea\Helper\DatabaseHelper; use Alchemy\Phrasea\Helper\DatabaseHelper;
use Alchemy\Phrasea\Helper\PathHelper; use Alchemy\Phrasea\Helper\PathHelper;
@@ -325,17 +322,12 @@ class Root implements ControllerProviderInterface
$error = false; $error = false;
$status = \databox_status::getStatus($app, $databox_id)[$bit];
$databox = $app['phraseanet.appbox']->get_databox((int) $databox_id);
try { try {
\databox_status::deleteStatus($app, $app['phraseanet.appbox']->get_databox($databox_id), $bit); \databox_status::deleteStatus($app, $app['phraseanet.appbox']->get_databox($databox_id), $bit);
} catch (\Exception $e) { } catch (\Exception $e) {
$error = true; $error = true;
} }
$app['dispatcher']->dispatch(PhraseaEvents::DATABOX_DELETE_STATUS, new DeleteStatusEvent($databox, $status));
return $app->json(['success' => !$error]); return $app->json(['success' => !$error]);
}) })
->bind('admin_statusbit_delete') ->bind('admin_statusbit_delete')
@@ -357,8 +349,6 @@ class Root implements ControllerProviderInterface
'labels_off' => $request->request->get('labels_off', []), 'labels_off' => $request->request->get('labels_off', []),
]; ];
$databox = $app['phraseanet.appbox']->get_databox((int) $databox_id);
\databox_status::updateStatus($app, $databox_id, $bit, $properties); \databox_status::updateStatus($app, $databox_id, $bit, $properties);
if (null !== $request->request->get('delete_icon_off')) { if (null !== $request->request->get('delete_icon_off')) {
@@ -453,10 +443,6 @@ class Root implements ControllerProviderInterface
} }
} }
$status = \databox_status::getStatus($app, $databox_id)[$bit];
$app['dispatcher']->dispatch(PhraseaEvents::DATABOX_UPDATE_STATUS, new UpdateStatusEvent($databox, $status));
return $app->redirectPath('database_display_statusbit', ['databox_id' => $databox_id, 'success' => 1]); return $app->redirectPath('database_display_statusbit', ['databox_id' => $databox_id, 'success' => 1]);
})->assert('databox_id', '\d+') })->assert('databox_id', '\d+')
->assert('bit', '\d+') ->assert('bit', '\d+')

View File

@@ -11,10 +11,10 @@
namespace Alchemy\Phrasea\Controller\Api; namespace Alchemy\Phrasea\Controller\Api;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordCreatedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents; use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordMetadataChangedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent; 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;

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\Record\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordMetadataChangedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent; 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;

View File

@@ -11,10 +11,10 @@
namespace Alchemy\Phrasea\Controller\Prod; namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordCreatedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents; use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordMetadataChangedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent; 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;

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\RecordCollectionChangedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordCollectionChangedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents; 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;

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\Record\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent; 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;

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\RecordDeletedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordDeletedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents; 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;

View File

@@ -13,8 +13,8 @@ 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\RecordEvents; use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent; 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;

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\Record\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordOriginalNameChangedEvent; 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;

View File

@@ -14,8 +14,8 @@ 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\RecordEvent\RecordCreatedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordCreatedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents; 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;

View File

@@ -11,8 +11,8 @@
namespace Alchemy\Phrasea\Controller\Thesaurus; namespace Alchemy\Phrasea\Controller\Thesaurus;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordMetadataChangedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents; 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;

View File

@@ -1,29 +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\DataboxEvent;
class DeleteStatusEvent extends DataboxEvent
{
private $status;
public function __construct(\databox $databox, array $status)
{
$this->status = $status;
parent::__construct($databox);
}
public function getStatus()
{
return $this->status;
}
}

View File

@@ -1,42 +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\DataboxEvent;
class UpdateStructureFieldEvent extends DataboxEvent
{
private $field;
private $data;
public function __construct(\databox $databox, \databox_field $field, $data)
{
$this->field = $field;
$this->data = $data;
parent::__construct($databox);
}
/**
* @return \databox_field
*/
public function getField()
{
return $this->field;
}
/**
* @return array
*/
public function getData()
{
return $this->data;
}
}

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Core\Event\RecordEvent; namespace Alchemy\Phrasea\Core\Event\Record;
class RecordCollectionChangedEvent extends RecordEvent class RecordCollectionChangedEvent extends RecordEvent
{ {

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Core\Event\RecordEvent; namespace Alchemy\Phrasea\Core\Event\Record;
class RecordCreatedEvent extends RecordEvent class RecordCreatedEvent extends RecordEvent
{} {}

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Core\Event\RecordEvent; namespace Alchemy\Phrasea\Core\Event\Record;
class RecordDeletedEvent extends RecordEvent class RecordDeletedEvent extends RecordEvent
{ {

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Core\Event\RecordEvent; namespace Alchemy\Phrasea\Core\Event\Record;
use Alchemy\Phrasea\Model\RecordInterface; use Alchemy\Phrasea\Model\RecordInterface;
use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\Event;

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Core\Event\RecordEvent; namespace Alchemy\Phrasea\Core\Event\Record;
final class RecordEvents final class RecordEvents
{ {

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Core\Event\RecordEvent; namespace Alchemy\Phrasea\Core\Event\Record;
class RecordIndexEvent extends RecordEvent class RecordIndexEvent extends RecordEvent
{ {

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Core\Event\RecordEvent; namespace Alchemy\Phrasea\Core\Event\Record;
class RecordMetadataChangedEvent extends RecordEvent class RecordMetadataChangedEvent extends RecordEvent
{ {

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Core\Event\RecordEvent; namespace Alchemy\Phrasea\Core\Event\Record;
class RecordOriginalNameChangedEvent extends RecordEvent class RecordOriginalNameChangedEvent extends RecordEvent
{ {

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Core\Event\RecordEvent; namespace Alchemy\Phrasea\Core\Event\Record;
class RecordStatusChangedEvent extends RecordEvent class RecordStatusChangedEvent extends RecordEvent
{ {

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Core\Event\RecordEvent; namespace Alchemy\Phrasea\Core\Event\Record;
class RecordSubDefinitionCreatedEvent extends RecordEvent class RecordSubDefinitionCreatedEvent extends RecordEvent
{ {

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Core\Event\RecordEvent; namespace Alchemy\Phrasea\Core\Event\Record;
class RecordSubDefinitionSubstitutedEvent extends RecordEvent class RecordSubDefinitionSubstitutedEvent extends RecordEvent
{ {

View File

@@ -9,9 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Core\Event\DataboxEvent; namespace Alchemy\Phrasea\Core\Event\Record\Structure;
class DataboxIndexEvent extends DataboxEvent class FieldDeletedEvent extends FieldEvent
{ {
} }

View File

@@ -9,17 +9,17 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Core\Event\DataboxEvent; namespace Alchemy\Phrasea\Core\Event\Record\Structure;
class DeleteStructureFieldEvent extends DataboxEvent abstract class FieldEvent extends RecordStructureEvent
{ {
private $field; private $field;
public function __construct(\databox $databox, \databox_field $field) public function __construct(\databox $databox, \databox_field $field)
{ {
$this->field = $field;
parent::__construct($databox); parent::__construct($databox);
$this->field = $field;
} }
/** /**

View File

@@ -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\Record\Structure;
class FieldUpdatedEvent extends FieldEvent
{
}

View File

@@ -9,11 +9,11 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Core\Event\DataboxEvent; namespace Alchemy\Phrasea\Core\Event\Record\Structure;
use Symfony\Component\EventDispatcher\Event as SfEvent; use Symfony\Component\EventDispatcher\Event;
class DataboxEvent extends SfEvent abstract class RecordStructureEvent extends Event
{ {
private $databox; private $databox;

View File

@@ -0,0 +1,20 @@
<?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\Record\Structure;
final class RecordStructureEvents
{
const FIELD_UPDATED = 'record_structure.field.changed';
const FIELD_DELETED = 'record_structure.field.deleted';
const STATUS_BIT_UPDATED = 'record_structure.status_bit.updated';
const STATUS_BIT_DELETED = 'record_structure.status_bit.deleted';
}

View File

@@ -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\Record\Structure;
class StatusBitDeletedEvent extends StatusBitEvent
{
}

View File

@@ -9,21 +9,21 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Core\Event\DataboxEvent; namespace Alchemy\Phrasea\Core\Event\Record\Structure;
class UpdateStatusEvent extends DataboxEvent abstract class StatusBitEvent extends RecordStructureEvent
{ {
private $status; private $bit;
public function __construct(\databox $databox, array $status) public function __construct(\databox $databox, $bit)
{ {
$this->status = $status;
parent::__construct($databox); parent::__construct($databox);
$this->bit = $bit;
} }
public function getStatus() public function getBit()
{ {
return $this->status; return $this->bit;
} }
} }

View File

@@ -0,0 +1,29 @@
<?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\Record\Structure;
class StatusBitUpdatedEvent extends StatusBitEvent
{
private $properties;
public function __construct(\databox $databox, $bit, array $properties)
{
parent::__construct($databox, $bit);
$this->properties = $properties;
}
public function getProperties()
{
return $this->properties;
}
}

View File

@@ -42,14 +42,6 @@ final class PhraseaEvents
const EXPORT_MAIL_FAILURE = 'export.mail-failure'; const EXPORT_MAIL_FAILURE = 'export.mail-failure';
const EXPORT_CREATE = 'export.create'; const EXPORT_CREATE = 'export.create';
const DATABOX_UPDATE_FIELD = 'databox.update.field';
const DATABOX_DELETE_FIELD = 'databox.delete.field';
const DATABOX_UPDATE_STATUS = 'databox.create.status';
const DATABOX_DELETE_STATUS = 'databox.delete.status';
const COLLECTION_CHANGE_NAME = 'collection.name'; const COLLECTION_CHANGE_NAME = 'collection.name';
const COLLECTION_CREATE = 'collection.create'; const COLLECTION_CREATE = 'collection.create';

View File

@@ -12,8 +12,8 @@
namespace Alchemy\Phrasea\Media; namespace Alchemy\Phrasea\Media;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordSubDefinitionCreatedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordSubDefinitionCreatedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents; use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
use MediaAlchemyst\Alchemyst; use MediaAlchemyst\Alchemyst;
use MediaAlchemyst\Specification\SpecificationInterface; use MediaAlchemyst\Specification\SpecificationInterface;
use MediaVorus\MediaVorus; use MediaVorus\MediaVorus;

View File

@@ -12,8 +12,8 @@
namespace Alchemy\Phrasea\Media; namespace Alchemy\Phrasea\Media;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMediaSubstitutedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordMediaSubstitutedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents; use Alchemy\Phrasea\Core\Event\Record\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;

View File

@@ -11,8 +11,8 @@
namespace Alchemy\Phrasea\Metadata; namespace Alchemy\Phrasea\Metadata;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents; use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordMetadataChangedEvent;
use PHPExiftool\Driver\Metadata\Metadata; use PHPExiftool\Driver\Metadata\Metadata;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;

View File

@@ -12,8 +12,8 @@
namespace Alchemy\Phrasea\TaskManager\Job; namespace Alchemy\Phrasea\TaskManager\Job;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents; use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordCreatedEvent; 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;

View File

@@ -12,10 +12,10 @@
namespace Alchemy\Phrasea\TaskManager\Job; 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\Record\RecordCollectionChangedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordDeletedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordDeletedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents; use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordStatusChangedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordStatusChangedEvent;
use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\TaskManager\Editor\RecordMoverEditor; use Alchemy\Phrasea\TaskManager\Editor\RecordMoverEditor;
use JMS\Serializer\EventDispatcher\EventDispatcher; use JMS\Serializer\EventDispatcher\EventDispatcher;

View File

@@ -10,8 +10,8 @@
*/ */
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordMetadataChangedEvent;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordEvents; use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class caption_field implements cache_cacheableInterface class caption_field implements cache_cacheableInterface

View File

@@ -10,6 +10,10 @@
*/ */
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Event\Record\Structure\FieldDeletedEvent;
use Alchemy\Phrasea\Core\Event\Record\Structure\FieldEvent;
use Alchemy\Phrasea\Core\Event\Record\Structure\FieldUpdatedEvent;
use Alchemy\Phrasea\Core\Event\Record\Structure\RecordStructureEvents;
use Alchemy\Phrasea\Vocabulary; use Alchemy\Phrasea\Vocabulary;
use Alchemy\Phrasea\Vocabulary\ControlProvider\ControlProviderInterface; use Alchemy\Phrasea\Vocabulary\ControlProvider\ControlProviderInterface;
use Alchemy\Phrasea\Metadata\Tag\Nosource; use Alchemy\Phrasea\Metadata\Tag\Nosource;
@@ -359,6 +363,8 @@ class databox_field implements cache_cacheableInterface
$this->delete_data_from_cache(); $this->delete_data_from_cache();
$this->databox->saveStructure($dom_struct); $this->databox->saveStructure($dom_struct);
$this->dispatchEvent(RecordStructureEvents::FIELD_DELETED, new FieldDeletedEvent($databox, $this));
return; return;
} }
@@ -467,9 +473,16 @@ class databox_field implements cache_cacheableInterface
$this->delete_data_from_cache(); $this->delete_data_from_cache();
$this->databox->saveStructure($dom_struct); $this->databox->saveStructure($dom_struct);
$this->dispatchEvent(RecordStructureEvents::FIELD_UPDATED, new FieldUpdatedEvent($databox, $this));
return $this; return $this;
} }
private function dispatchEvent($eventName, FieldEvent $event = null)
{
$this->app['dispatcher']->dispatch($eventName, $event);
}
/** /**
* Sets a localized label for the field. * Sets a localized label for the field.
* *

View File

@@ -257,6 +257,8 @@ class databox_status
unset(self::$_status[$databox->get_sbas_id()]->status[$bit]); unset(self::$_status[$databox->get_sbas_id()]->status[$bit]);
$app['dispatcher']->dispatch(RecordStructureEvents::STATUS_BIT_DELETED, new StatusBitDeletedEvent($databox, $bit));
return true; return true;
} }
} }
@@ -348,6 +350,9 @@ class databox_status
if ( ! isset(self::$_status[$sbas_id]->status[$bit]['img_off'])) { if ( ! isset(self::$_status[$sbas_id]->status[$bit]['img_off'])) {
self::$_status[$sbas_id]->status[$bit]['img_off'] = null; self::$_status[$sbas_id]->status[$bit]['img_off'] = null;
} }
$properties = self::$_status[$sbas_id]->status[$bit];
$app['dispatcher']->dispatch(RecordStructureEvents::STATUS_BIT_UPDATED, new StatusBitUpdatedEvent($databox, $bit, $properties));
} }
return false; return false;

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\Record\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEvent\RecordMetadataChangedEvent; use Alchemy\Phrasea\Core\Event\Record\RecordMetadataChangedEvent;
class module_console_fieldsMerge extends Command class module_console_fieldsMerge extends Command
{ {