mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Refactor query context
No more private collection map, uses new features from LimitedStructure. From now on, Context tries to return Field objects instead of strings. New context methods: - getUnrestrictedFields() - getPrivateFields() - localizeField(Field) (signature changed) - localizeFieldName(string) QueryContext::localizeField() now takes a Field object, use localizeFieldName() if you want to pass a string. Field::getIndexFieldName() renamed to Field::getIndexField(). Raw index fields are now obtained with Field::getIndexField(true).
This commit is contained in:
@@ -17,7 +17,7 @@ class QueryContextTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$structure = $this->prophesize(Structure::class)->reveal();
|
||||
$available_locales = ['ab', 'cd', 'ef'];
|
||||
$context = new QueryContext($structure, [], $available_locales, 'fr');
|
||||
$context = new QueryContext($structure, $available_locales, 'fr');
|
||||
$narrowed = $context->narrowToFields(['some_field']);
|
||||
$this->assertEquals(['some_field'], $narrowed->getFields());
|
||||
}
|
||||
@@ -30,7 +30,7 @@ class QueryContextTest extends \PHPUnit_Framework_TestCase
|
||||
$structure->get('foo')->willReturn($public_field);
|
||||
$structure->get('bar')->willReturn($restricted_field);
|
||||
|
||||
$context = new QueryContext($structure->reveal(), [], [], 'fr');
|
||||
$context = new QueryContext($structure->reveal(), [], 'fr');
|
||||
$this->assertEquals('caption.foo', $context->normalizeField('foo'));
|
||||
$this->assertEquals('private_caption.bar', $context->normalizeField('bar'));
|
||||
}
|
||||
|
Reference in New Issue
Block a user