mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 21:43:18 +00:00
PHRAS-2769 delete record
This commit is contained in:
@@ -14,6 +14,8 @@ use Alchemy\Phrasea\Application\Helper\EntityManagerAware;
|
|||||||
use Alchemy\Phrasea\Application\Helper\SearchEngineAware;
|
use Alchemy\Phrasea\Application\Helper\SearchEngineAware;
|
||||||
use Alchemy\Phrasea\Controller\Controller;
|
use Alchemy\Phrasea\Controller\Controller;
|
||||||
use Alchemy\Phrasea\Controller\RecordsRequest;
|
use Alchemy\Phrasea\Controller\RecordsRequest;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\DeleteEvent;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
||||||
use Alchemy\Phrasea\Core\Event\RecordEdit;
|
use Alchemy\Phrasea\Core\Event\RecordEdit;
|
||||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||||
use Alchemy\Phrasea\Model\Entities\BasketElement;
|
use Alchemy\Phrasea\Model\Entities\BasketElement;
|
||||||
@@ -234,7 +236,7 @@ class RecordController extends Controller
|
|||||||
if($trashCollectionsBySbasId[$sbasId] !== null) {
|
if($trashCollectionsBySbasId[$sbasId] !== null) {
|
||||||
if($record->getCollection()->get_coll_id() == $trashCollectionsBySbasId[$sbasId]->get_coll_id()) {
|
if($record->getCollection()->get_coll_id() == $trashCollectionsBySbasId[$sbasId]->get_coll_id()) {
|
||||||
// record is already in trash so delete it
|
// record is already in trash so delete it
|
||||||
$record->delete();
|
$this->getEventDispatcher()->dispatch(RecordEvents::DELETE, new DeleteEvent($record));
|
||||||
} else {
|
} else {
|
||||||
// move to trash collection
|
// move to trash collection
|
||||||
$record->move_to_collection($trashCollectionsBySbasId[$sbasId], $this->getApplicationBox());
|
$record->move_to_collection($trashCollectionsBySbasId[$sbasId], $this->getApplicationBox());
|
||||||
@@ -247,7 +249,7 @@ class RecordController extends Controller
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// no trash collection, delete
|
// no trash collection, delete
|
||||||
$record->delete();
|
$this->getEventDispatcher()->dispatch(RecordEvents::DELETE, new DeleteEvent($record));
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
}
|
}
|
||||||
|
@@ -13,8 +13,10 @@ namespace Alchemy\Phrasea\Core\Event\Record;
|
|||||||
|
|
||||||
final class RecordEvents
|
final class RecordEvents
|
||||||
{
|
{
|
||||||
const CREATED = 'record.created';
|
const CREATED = 'record.created';
|
||||||
const DELETED = 'record.deleted';
|
const DELETED = 'record.deleted';
|
||||||
|
const DELETE = 'record.delete';
|
||||||
|
|
||||||
// Change
|
// Change
|
||||||
const COLLECTION_CHANGED = 'record.collection_changed';
|
const COLLECTION_CHANGED = 'record.collection_changed';
|
||||||
const METADATA_CHANGED = 'record.metadata_changed';
|
const METADATA_CHANGED = 'record.metadata_changed';
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
namespace Alchemy\Phrasea\Core\Event\Subscriber;
|
namespace Alchemy\Phrasea\Core\Event\Subscriber;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Event\Record\CollectionChangedEvent;
|
use Alchemy\Phrasea\Core\Event\Record\CollectionChangedEvent;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\DeleteEvent;
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvent;
|
use Alchemy\Phrasea\Core\Event\Record\RecordEvent;
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
||||||
use Alchemy\Phrasea\Core\Event\Record\SubdefinitionCreateEvent;
|
use Alchemy\Phrasea\Core\Event\Record\SubdefinitionCreateEvent;
|
||||||
@@ -32,6 +33,7 @@ class RecordEditSubscriber implements EventSubscriberInterface
|
|||||||
RecordEvents::ROTATE => 'onRecordChange',
|
RecordEvents::ROTATE => 'onRecordChange',
|
||||||
RecordEvents::COLLECTION_CHANGED => 'onCollectionChanged',
|
RecordEvents::COLLECTION_CHANGED => 'onCollectionChanged',
|
||||||
RecordEvents::SUBDEFINITION_CREATE => 'onSubdefinitionCreate',
|
RecordEvents::SUBDEFINITION_CREATE => 'onSubdefinitionCreate',
|
||||||
|
RecordEvents::DELETE => 'onDelete',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,6 +59,12 @@ class RecordEditSubscriber implements EventSubscriberInterface
|
|||||||
$recordAdapter->rebuild_subdefs();
|
$recordAdapter->rebuild_subdefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onDelete(DeleteEvent $event)
|
||||||
|
{
|
||||||
|
$recordAdapter = $this->convertToRecordAdapter($event->getRecord());
|
||||||
|
$recordAdapter->delete();
|
||||||
|
}
|
||||||
|
|
||||||
public function onEdit(RecordEdit $event)
|
public function onEdit(RecordEdit $event)
|
||||||
{
|
{
|
||||||
static $into = false;
|
static $into = false;
|
||||||
|
Reference in New Issue
Block a user