mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
PHRAS-3604 remove deleted record from a publication
This commit is contained in:
@@ -230,21 +230,4 @@ class FeedItem
|
|||||||
{
|
{
|
||||||
return new \record_adapter($app, $this->getSbasId(), $this->getRecordId(), $this->getOrd());
|
return new \record_adapter($app, $this->getSbasId(), $this->getRecordId(), $this->getOrd());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Application $app
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isRecordExist(Application $app)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return (new \record_adapter($app, $this->getSbasId(), $this->getRecordId(), $this->getOrd())) != null ? true : false ;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
// remove feeditem from the feed entry if record don't exist
|
|
||||||
$app['orm.em']->remove($this);
|
|
||||||
$app['orm.em']->flush();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
81
lib/classes/patch/415PHRAS3604.php
Normal file
81
lib/classes/patch/415PHRAS3604.php
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Alchemy\Phrasea\Model\Repositories\FeedItemRepository;
|
||||||
|
use Alchemy\Phrasea\Model\Entities\FeedItem;
|
||||||
|
|
||||||
|
class patch_415PHRAS3604 implements patchInterface
|
||||||
|
{
|
||||||
|
/** @var string */
|
||||||
|
private $release = '4.1.5';
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
private $concern = [base::APPLICATION_BOX];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function get_release()
|
||||||
|
{
|
||||||
|
return $this->release;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function concern()
|
||||||
|
{
|
||||||
|
return $this->concern;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function require_all_upgrades()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getDoctrineMigrations()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function apply(base $base, Application $app)
|
||||||
|
{
|
||||||
|
if ($base->get_base_type() === base::DATA_BOX) {
|
||||||
|
$this->patch_databox($base, $app);
|
||||||
|
}
|
||||||
|
elseif ($base->get_base_type() === base::APPLICATION_BOX) {
|
||||||
|
$this->patch_appbox($base, $app);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function patch_databox(base $databox, Application $app)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private function patch_appbox(base $databox, Application $app)
|
||||||
|
{
|
||||||
|
/** @var FeedItemRepository $feedItemRepository */
|
||||||
|
$feedItemRepository = $app['repo.feed-items'];
|
||||||
|
|
||||||
|
/** @var FeedItem $feedItem */
|
||||||
|
foreach ($feedItemRepository->findAll() as $feedItem) {
|
||||||
|
// if the record is not found, delete the feedItem
|
||||||
|
if ($app->findDataboxById($feedItem->getSbasId())->getRecordRepository()->find($feedItem->getRecordId()) == null) {
|
||||||
|
$app['orm.em']->remove($feedItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$app['orm.em']->flush();
|
||||||
|
}
|
||||||
|
}
|
@@ -32,6 +32,7 @@ use Alchemy\Phrasea\Media\TechnicalData;
|
|||||||
use Alchemy\Phrasea\Media\TechnicalDataSet;
|
use Alchemy\Phrasea\Media\TechnicalDataSet;
|
||||||
use Alchemy\Phrasea\Metadata\Tag\TfBasename;
|
use Alchemy\Phrasea\Metadata\Tag\TfBasename;
|
||||||
use Alchemy\Phrasea\Metadata\Tag\TfFilename;
|
use Alchemy\Phrasea\Metadata\Tag\TfFilename;
|
||||||
|
use Alchemy\Phrasea\Model\Repositories\FeedItemRepository;
|
||||||
use Alchemy\Phrasea\Model\Entities\OrderElement;
|
use Alchemy\Phrasea\Model\Entities\OrderElement;
|
||||||
use Alchemy\Phrasea\Model\Entities\User;
|
use Alchemy\Phrasea\Model\Entities\User;
|
||||||
use Alchemy\Phrasea\Model\RecordInterface;
|
use Alchemy\Phrasea\Model\RecordInterface;
|
||||||
@@ -2146,6 +2147,14 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
$this->app['orm.em']->remove($basket_element);
|
$this->app['orm.em']->remove($basket_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var FeedItemRepository $feedItemRepository */
|
||||||
|
$feedItemRepository = $this->app['repo.feed-items'];
|
||||||
|
|
||||||
|
// remove the record from publications
|
||||||
|
foreach($feedItemRepository->findBy(['recordId' => $this->getRecordId()]) as $feedItem) {
|
||||||
|
$this->app['orm.em']->remove($feedItem);
|
||||||
|
}
|
||||||
|
|
||||||
$this->app['orm.em']->flush();
|
$this->app['orm.em']->flush();
|
||||||
|
|
||||||
$this->app['filesystem']->remove($ftodel);
|
$this->app['filesystem']->remove($ftodel);
|
||||||
|
@@ -1,10 +1,9 @@
|
|||||||
{% import 'common/thumbnail.html.twig' as thumbnail %}
|
{% import 'common/thumbnail.html.twig' as thumbnail %}
|
||||||
|
|
||||||
{% if item.isRecordExist(app) %}
|
|
||||||
|
|
||||||
{% set record = item.record(app) %}
|
{% set record = item.record(app) %}
|
||||||
|
|
||||||
<div style="width:{{ images_size+30 }}px;"
|
<div style="width:{{ images_size+30 }}px;"
|
||||||
sbas="{{ record.databoxId }}"
|
sbas="{{ record.databoxId }}"
|
||||||
id="{{'PUBLI_' ~ entry.id ~ '_' ~ record.id }}"
|
id="{{'PUBLI_' ~ entry.id ~ '_' ~ record.id }}"
|
||||||
class="IMGT diapo type-{{ record.type }} open-preview-action"
|
class="IMGT diapo type-{{ record.type }} open-preview-action"
|
||||||
@@ -82,6 +81,5 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
</div>
|
||||||
|
Reference in New Issue
Block a user