mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +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));
|
$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());
|
$recordTransformer = new RecordTransformer($subdefTransformer, new TechnicalDataTransformer());
|
||||||
$storyTransformer = new StoryTransformer($subdefTransformer, $recordTransformer);
|
$storyTransformer = new StoryTransformer($subdefTransformer, $recordTransformer);
|
||||||
$compositeTransformer = new V1SearchCompositeResultTransformer($recordTransformer, $storyTransformer);
|
$compositeTransformer = new V1SearchCompositeResultTransformer($recordTransformer, $storyTransformer);
|
||||||
@@ -1269,20 +1269,20 @@ class V1Controller extends Controller
|
|||||||
*/
|
*/
|
||||||
private function resolveSearchIncludes(Request $request)
|
private function resolveSearchIncludes(Request $request)
|
||||||
{
|
{
|
||||||
if (!$request->attributes->get('_extended', false)) {
|
if ($request->attributes->get('_extended', false)) {
|
||||||
return [];
|
return [
|
||||||
|
'results.stories.records.subdefs',
|
||||||
|
'results.stories.records.metadata',
|
||||||
|
'results.stories.records.caption',
|
||||||
|
'results.stories.records.status',
|
||||||
|
'results.records.subdefs',
|
||||||
|
'results.records.metadata',
|
||||||
|
'results.records.caption',
|
||||||
|
'results.records.status',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [];
|
||||||
'results.stories.records.subdefs',
|
|
||||||
'results.stories.records.metadata',
|
|
||||||
'results.stories.records.caption',
|
|
||||||
'results.stories.records.status',
|
|
||||||
'results.records.subdefs',
|
|
||||||
'results.records.metadata',
|
|
||||||
'results.records.caption',
|
|
||||||
'results.records.status',
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1293,16 +1293,16 @@ class V1Controller extends Controller
|
|||||||
*/
|
*/
|
||||||
private function resolveSearchRecordsIncludes(Request $request)
|
private function resolveSearchRecordsIncludes(Request $request)
|
||||||
{
|
{
|
||||||
if (!$request->attributes->get('_extended', false)) {
|
if ($request->attributes->get('_extended', false)) {
|
||||||
return [];
|
return [
|
||||||
|
'results.subdefs',
|
||||||
|
'results.metadata',
|
||||||
|
'results.caption',
|
||||||
|
'results.status',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [];
|
||||||
'results.subdefs',
|
|
||||||
'results.metadata',
|
|
||||||
'results.caption',
|
|
||||||
'results.status',
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -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;
|
namespace Alchemy\Phrasea\Databox\Caption;
|
||||||
|
|
||||||
use Assert\Assertion;
|
|
||||||
|
|
||||||
class CaptionRepository
|
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;
|
namespace Alchemy\Phrasea\Databox\Caption;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Controller\LazyLocator;
|
use Alchemy\Phrasea\Controller\LazyLocator;
|
||||||
|
use Alchemy\Phrasea\Databox\ClosureDataboxBoundRepositoryFactory;
|
||||||
use Alchemy\Phrasea\Databox\DataboxBoundRepositoryProvider;
|
use Alchemy\Phrasea\Databox\DataboxBoundRepositoryProvider;
|
||||||
use Alchemy\Phrasea\Databox\DataboxConnectionProvider;
|
use Alchemy\Phrasea\Databox\DataboxConnectionProvider;
|
||||||
use Alchemy\Phrasea\Record\RecordReference;
|
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) {
|
$app['provider.repo.caption'] = $app->share(function (Application $app) {
|
||||||
$connectionProvider = new DataboxConnectionProvider($app['phraseanet.appbox']);
|
return new DataboxBoundRepositoryProvider(
|
||||||
$factoryProvider = $app['provider.factory.caption'];
|
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 CaptionRepository(
|
||||||
|
$dataRepository,
|
||||||
return new DataboxBoundRepositoryProvider($repositoryFactory);
|
$captionFactoryProvider($databoxId)
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$app['service.caption'] = $app->share(function (Application $app) {
|
$app['service.caption'] = $app->share(function (Application $app) {
|
||||||
@@ -45,6 +59,6 @@ class CaptionServiceProvider implements ServiceProviderInterface
|
|||||||
|
|
||||||
public function boot(Application $app)
|
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