PHRAS-1158_STAMP-CHANGE-COLL

change : stamp reset moved to event subscriber
This commit is contained in:
Jean-Yves Gaulier
2016-06-16 11:47:34 +02:00
parent 51ff2e040a
commit c040511320
2 changed files with 12 additions and 2 deletions

View File

@@ -10,6 +10,7 @@
namespace Alchemy\Phrasea\Core\Event\Subscriber;
use Alchemy\Phrasea\Core\Event\Record\CollectionChangedEvent;
use Alchemy\Phrasea\Core\Event\Record\RecordEvent;
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
use Alchemy\Phrasea\Core\Event\RecordEdit;
@@ -27,6 +28,7 @@ class RecordEditSubscriber implements EventSubscriberInterface
PhraseaEvents::RECORD_EDIT => 'onEdit',
PhraseaEvents::RECORD_UPLOAD => 'onEdit',
RecordEvents::ROTATE => 'onRecordChange',
RecordEvents::COLLECTION_CHANGED => 'onCollectionChanged',
);
}
@@ -40,6 +42,12 @@ class RecordEditSubscriber implements EventSubscriberInterface
$this->appboxLocator = $appboxLocator;
}
public function onCollectionChanged(CollectionChangedEvent $event)
{
$recordAdapter = $this->convertToRecordAdapter($event->getRecord());
$recordAdapter->clearStampCache();
}
public function onEdit(RecordEdit $event)
{
$recordAdapter = $this->convertToRecordAdapter($event->getRecord());
@@ -57,6 +65,8 @@ class RecordEditSubscriber implements EventSubscriberInterface
if ($editDateField instanceof \databox_field) {
$this->updateRecord($recordAdapter, $editDateField);
}
$recordAdapter->clearStampCache();
}
/**

View File

@@ -477,7 +477,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
// remove stamp BEFORE changing collection since it uses the collection id :(
// todo : change clearStampCache() to be agnostic of collection
$this->clearStampCache();
// $this->clearStampCache();
$sql = "UPDATE record SET moddate = NOW(), coll_id = :coll_id WHERE record_id =:record_id";
@@ -997,7 +997,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
$this->set_metadata($param, $this->getDatabox());
}
$this->clearStampCache();
// $this->clearStampCache();
$xml = new DOMDocument();
$xml->loadXML($this->app['serializer.caption']->serialize($this->get_caption(), CaptionSerializer::SERIALIZE_XML, true));