mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Remove unused fields. Extract methods in phrasea
This commit is contained in:
@@ -16,12 +16,8 @@ use Symfony\Component\Translation\TranslatorInterface;
|
|||||||
|
|
||||||
class phrasea
|
class phrasea
|
||||||
{
|
{
|
||||||
private static $_bas2sbas = false;
|
|
||||||
private static $_sbas_names = false;
|
private static $_sbas_names = false;
|
||||||
private static $_sbas_labels = false;
|
private static $_sbas_labels = false;
|
||||||
private static $_coll2bas = false;
|
|
||||||
private static $_bas2coll = false;
|
|
||||||
private static $_bas_labels = false;
|
|
||||||
private static $_sbas_params = false;
|
private static $_sbas_params = false;
|
||||||
|
|
||||||
const CACHE_BAS_2_SBAS = 'bas_2_sbas';
|
const CACHE_BAS_2_SBAS = 'bas_2_sbas';
|
||||||
@@ -100,9 +96,7 @@ class phrasea
|
|||||||
|
|
||||||
public static function sbasFromBas(Application $app, $base_id)
|
public static function sbasFromBas(Application $app, $base_id)
|
||||||
{
|
{
|
||||||
/** @var CollectionReferenceRepository $repository */
|
$reference = self::getCollectionReferenceRepository($app)->find($base_id);
|
||||||
$repository = $app['repo.collection-references'];
|
|
||||||
$reference = $repository->find($base_id);
|
|
||||||
|
|
||||||
if ($reference) {
|
if ($reference) {
|
||||||
return $reference->getDataboxId();
|
return $reference->getDataboxId();
|
||||||
@@ -113,9 +107,7 @@ class phrasea
|
|||||||
|
|
||||||
public static function baseFromColl($sbas_id, $coll_id, Application $app)
|
public static function baseFromColl($sbas_id, $coll_id, Application $app)
|
||||||
{
|
{
|
||||||
/** @var CollectionReferenceRepository $repository */
|
$reference = self::getCollectionReferenceRepository($app)->findByCollectionId($sbas_id, $coll_id);
|
||||||
$repository = $app['repo.collection-references'];
|
|
||||||
$reference = $repository->findByCollectionId($sbas_id, $coll_id);
|
|
||||||
|
|
||||||
if ($reference) {
|
if ($reference) {
|
||||||
return $reference->getBaseId();
|
return $reference->getBaseId();
|
||||||
@@ -126,39 +118,32 @@ class phrasea
|
|||||||
|
|
||||||
public static function reset_baseDatas(appbox $appbox)
|
public static function reset_baseDatas(appbox $appbox)
|
||||||
{
|
{
|
||||||
self::$_coll2bas = self::$_bas2coll = self::$_bas_labels = self::$_bas2sbas = null;
|
$appbox->delete_data_from_cache([
|
||||||
$appbox->delete_data_from_cache(
|
self::CACHE_BAS_2_COLL,
|
||||||
[
|
self::CACHE_BAS_2_COLL,
|
||||||
self::CACHE_BAS_2_COLL
|
self::CACHE_BAS_LABELS,
|
||||||
, self::CACHE_BAS_2_COLL
|
self::CACHE_SBAS_FROM_BAS,
|
||||||
, self::CACHE_BAS_LABELS
|
]);
|
||||||
, self::CACHE_SBAS_FROM_BAS
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function reset_sbasDatas(appbox $appbox)
|
public static function reset_sbasDatas(appbox $appbox)
|
||||||
{
|
{
|
||||||
self::$_sbas_names = self::$_sbas_labels = self::$_sbas_params = self::$_bas2sbas = null;
|
self::$_sbas_names = self::$_sbas_labels = self::$_sbas_params = null;
|
||||||
$appbox->delete_data_from_cache(
|
$appbox->delete_data_from_cache([
|
||||||
[
|
self::CACHE_SBAS_NAMES,
|
||||||
self::CACHE_SBAS_NAMES,
|
self::CACHE_SBAS_LABELS,
|
||||||
self::CACHE_SBAS_LABELS,
|
self::CACHE_SBAS_FROM_BAS,
|
||||||
self::CACHE_SBAS_FROM_BAS,
|
self::CACHE_SBAS_PARAMS,
|
||||||
self::CACHE_SBAS_PARAMS,
|
]);
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function collFromBas(Application $app, $base_id)
|
public static function collFromBas(Application $app, $base_id)
|
||||||
{
|
{
|
||||||
/** @var CollectionReferenceRepository $repository */
|
$reference = self::getCollectionReferenceRepository($app)->find($base_id);
|
||||||
$repository = $app['repo.collection-references'];
|
|
||||||
$reference = $repository->find($base_id);
|
|
||||||
|
|
||||||
if ($reference) {
|
if ($reference) {
|
||||||
return $reference->getCollectionId();
|
return $reference->getCollectionId();
|
||||||
@@ -210,17 +195,14 @@ class phrasea
|
|||||||
|
|
||||||
public static function bas_labels($base_id, Application $app)
|
public static function bas_labels($base_id, Application $app)
|
||||||
{
|
{
|
||||||
/** @var CollectionReferenceRepository $repository */
|
$reference = self::getCollectionReferenceRepository($app)->find($base_id);
|
||||||
$referenceRepository = $app['repo.collection-references'];
|
|
||||||
$reference = $referenceRepository->find($base_id);
|
|
||||||
|
|
||||||
if (! $reference) {
|
if (! $reference) {
|
||||||
return $app->trans('collection.label.unknown');
|
return $app->trans('collection.label.unknown');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var CollectionRepositoryRegistry $collectionRepositoryRegistry */
|
$collectionRepository = self::getCollectionRepositoryRegistry($app)
|
||||||
$collectionRepositoryRegistry = $app['repo.collections-registry'];
|
->getRepositoryByDatabox($reference->getDataboxId());
|
||||||
$collectionRepository = $collectionRepositoryRegistry->getRepositoryByDatabox($reference->getDataboxId());
|
|
||||||
|
|
||||||
$collection = $collectionRepository->find($reference->getCollectionId());
|
$collection = $collectionRepository->find($reference->getCollectionId());
|
||||||
|
|
||||||
@@ -236,4 +218,22 @@ class phrasea
|
|||||||
|
|
||||||
return $collection->getCollection()->getName();
|
return $collection->getCollection()->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Application $app
|
||||||
|
* @return CollectionReferenceRepository
|
||||||
|
*/
|
||||||
|
private static function getCollectionReferenceRepository(Application $app)
|
||||||
|
{
|
||||||
|
return $app['repo.collection-references'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Application $app
|
||||||
|
* @return CollectionRepositoryRegistry
|
||||||
|
*/
|
||||||
|
private static function getCollectionRepositoryRegistry(Application $app)
|
||||||
|
{
|
||||||
|
return $app['repo.collections-registry'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user