mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Add touch capability to record_adapter.
This commit is contained in:
49
lib/Alchemy/Phrasea/Record/RecordUpdateSubscriber.php
Normal file
49
lib/Alchemy/Phrasea/Record/RecordUpdateSubscriber.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2016 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Record;
|
||||
|
||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvent;
|
||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
class RecordUpdateSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
RecordEvents::ROTATE => 'onRecordChange',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @var \appbox
|
||||
*/
|
||||
private $appbox;
|
||||
|
||||
public function __construct(\appbox $appbox)
|
||||
{
|
||||
$this->appbox = $appbox;
|
||||
}
|
||||
|
||||
public function onRecordChange(RecordEvent $recordEvent)
|
||||
{
|
||||
$record = $recordEvent->getRecord();
|
||||
|
||||
$databoxId = $record->getDataboxId();
|
||||
$recordId = $record->getRecordId();
|
||||
|
||||
$recordAdapter = $this->appbox->get_databox($databoxId)->getRecordRepository()->find($recordId);
|
||||
|
||||
if ($recordAdapter) {
|
||||
$recordAdapter->touch();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user