mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Subscriber is on DataRepository not actual repository
This commit is contained in:
@@ -1057,7 +1057,7 @@ class V1Controller extends Controller
|
||||
|
||||
$searchView = $this->buildSearchView($this->doSearch($request));
|
||||
|
||||
$subdefTransformer = new SubdefTransformer();
|
||||
$subdefTransformer = new SubdefTransformer($this->app['acl'], $this->getAuthenticatedUser(), new PermalinkTransformer());
|
||||
$recordTransformer = new RecordTransformer($subdefTransformer, new TechnicalDataTransformer());
|
||||
$storyTransformer = new StoryTransformer($subdefTransformer, $recordTransformer);
|
||||
$compositeTransformer = new V1SearchCompositeResultTransformer($recordTransformer, $storyTransformer);
|
||||
@@ -1269,10 +1269,7 @@ class V1Controller extends Controller
|
||||
*/
|
||||
private function resolveSearchIncludes(Request $request)
|
||||
{
|
||||
if (!$request->attributes->get('_extended', false)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if ($request->attributes->get('_extended', false)) {
|
||||
return [
|
||||
'results.stories.records.subdefs',
|
||||
'results.stories.records.metadata',
|
||||
@@ -1285,6 +1282,9 @@ class V1Controller extends Controller
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns requested includes
|
||||
*
|
||||
@@ -1293,10 +1293,7 @@ class V1Controller extends Controller
|
||||
*/
|
||||
private function resolveSearchRecordsIncludes(Request $request)
|
||||
{
|
||||
if (!$request->attributes->get('_extended', false)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if ($request->attributes->get('_extended', false)) {
|
||||
return [
|
||||
'results.subdefs',
|
||||
'results.metadata',
|
||||
@@ -1305,6 +1302,9 @@ class V1Controller extends Controller
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return int
|
||||
|
@@ -0,0 +1,43 @@
|
||||
<?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\Databox\Caption;
|
||||
|
||||
use Alchemy\Phrasea\Databox\DataboxBoundRepositoryFactory;
|
||||
use Alchemy\Phrasea\Databox\DataboxConnectionProvider;
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
|
||||
class CaptionDataRepositoryFactory implements DataboxBoundRepositoryFactory
|
||||
{
|
||||
/**
|
||||
* @var DataboxConnectionProvider
|
||||
*/
|
||||
private $connectionProvider;
|
||||
|
||||
/**
|
||||
* @var Cache
|
||||
*/
|
||||
private $cache;
|
||||
|
||||
public function __construct(DataboxConnectionProvider $connectionProvider, Cache $cache)
|
||||
{
|
||||
$this->connectionProvider = $connectionProvider;
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
public function createRepositoryFor($databoxId)
|
||||
{
|
||||
return new CachedCaptionDataRepository(
|
||||
new DbalCaptionDataRepository($this->connectionProvider->getConnection($databoxId)),
|
||||
$this->cache,
|
||||
sprintf('databox[%d]:', $databoxId)
|
||||
);
|
||||
}
|
||||
}
|
@@ -10,8 +10,6 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Databox\Caption;
|
||||
|
||||
use Assert\Assertion;
|
||||
|
||||
class CaptionRepository
|
||||
{
|
||||
/**
|
||||
|
@@ -1,60 +0,0 @@
|
||||
<?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\Databox\Caption;
|
||||
|
||||
use Alchemy\Phrasea\Databox\DataboxBoundRepositoryFactory;
|
||||
use Alchemy\Phrasea\Databox\DataboxConnectionProvider;
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
|
||||
class CaptionRepositoryFactory implements DataboxBoundRepositoryFactory
|
||||
{
|
||||
/**
|
||||
* @var DataboxConnectionProvider
|
||||
*/
|
||||
private $connectionProvider;
|
||||
|
||||
/**
|
||||
* @var Cache
|
||||
*/
|
||||
private $cache;
|
||||
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
private $captionFactoryProvider;
|
||||
|
||||
public function __construct(DataboxConnectionProvider $connectionProvider, Cache $cache, callable $captionFactoryProvider)
|
||||
{
|
||||
$this->connectionProvider = $connectionProvider;
|
||||
$this->cache = $cache;
|
||||
$this->captionFactoryProvider = $captionFactoryProvider;
|
||||
}
|
||||
|
||||
public function createRepositoryFor($databoxId)
|
||||
{
|
||||
$connection = $this->connectionProvider->getConnection($databoxId);
|
||||
|
||||
$dbalRepository = new DbalCaptionDataRepository($connection);
|
||||
$dataRepository = new CachedCaptionDataRepository($dbalRepository, $this->cache, sprintf('databox[%d]:', $databoxId));
|
||||
|
||||
$provider = $this->captionFactoryProvider;
|
||||
$factory = $provider($databoxId);
|
||||
|
||||
if (!is_callable($factory)) {
|
||||
throw new \UnexpectedValueException(sprintf(
|
||||
'Caption factory is expected to be callable, got %s',
|
||||
is_object($factory) ? get_class($factory) : gettype($factory)
|
||||
));
|
||||
}
|
||||
|
||||
return new CaptionRepository($dataRepository, $factory);
|
||||
}
|
||||
}
|
@@ -11,6 +11,7 @@
|
||||
namespace Alchemy\Phrasea\Databox\Caption;
|
||||
|
||||
use Alchemy\Phrasea\Controller\LazyLocator;
|
||||
use Alchemy\Phrasea\Databox\ClosureDataboxBoundRepositoryFactory;
|
||||
use Alchemy\Phrasea\Databox\DataboxBoundRepositoryProvider;
|
||||
use Alchemy\Phrasea\Databox\DataboxConnectionProvider;
|
||||
use Alchemy\Phrasea\Record\RecordReference;
|
||||
@@ -29,13 +30,26 @@ class CaptionServiceProvider implements ServiceProviderInterface
|
||||
};
|
||||
});
|
||||
|
||||
$app['provider.data_repo.caption'] = $app->share(function (Application $app) {
|
||||
return new DataboxBoundRepositoryProvider(new CaptionDataRepositoryFactory(
|
||||
new DataboxConnectionProvider($app['phraseanet.appbox']),
|
||||
$app['cache']
|
||||
));
|
||||
});
|
||||
|
||||
$app['provider.repo.caption'] = $app->share(function (Application $app) {
|
||||
$connectionProvider = new DataboxConnectionProvider($app['phraseanet.appbox']);
|
||||
$factoryProvider = $app['provider.factory.caption'];
|
||||
return new DataboxBoundRepositoryProvider(
|
||||
new ClosureDataboxBoundRepositoryFactory(function ($databoxId) use ($app) {
|
||||
/** @var CaptionDataRepository $dataRepository */
|
||||
$dataRepository = $app['provider.data_repo.caption']->getRepositoryForDatabox($databoxId);
|
||||
$captionFactoryProvider = $app['provider.factory.caption'];
|
||||
|
||||
$repositoryFactory = new CaptionRepositoryFactory($connectionProvider, $app['cache'], $factoryProvider);
|
||||
|
||||
return new DataboxBoundRepositoryProvider($repositoryFactory);
|
||||
return new CaptionRepository(
|
||||
$dataRepository,
|
||||
$captionFactoryProvider($databoxId)
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
$app['service.caption'] = $app->share(function (Application $app) {
|
||||
@@ -45,6 +59,6 @@ class CaptionServiceProvider implements ServiceProviderInterface
|
||||
|
||||
public function boot(Application $app)
|
||||
{
|
||||
$app['dispatcher']->addSubscriber(new CaptionCacheInvalider(new LazyLocator($app, 'provider.repo.caption')));
|
||||
$app['dispatcher']->addSubscriber(new CaptionCacheInvalider(new LazyLocator($app, 'provider.data_repo.caption')));
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,31 @@
|
||||
<?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\Databox;
|
||||
|
||||
class ClosureDataboxBoundRepositoryFactory implements DataboxBoundRepositoryFactory
|
||||
{
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
private $factory;
|
||||
|
||||
public function __construct(callable $factory)
|
||||
{
|
||||
$this->factory = $factory;
|
||||
}
|
||||
|
||||
public function createRepositoryFor($databoxId)
|
||||
{
|
||||
$factory = $this->factory;
|
||||
|
||||
return $factory($databoxId);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user