- *
- */
-class TranslatableStringHelper
+final class TranslatableStringHelper implements TranslatableStringHelperInterface
{
- /**
- *
- * @var RequestStack
- */
- private $requestStack;
-
- private $fallbackLocales;
-
- public function __construct(RequestStack $requestStack, Translator $translator)
+ private RequestStack $requestStack;
+
+ private TranslatorInterface $translator;
+
+ public function __construct(RequestStack $requestStack, TranslatorInterface $translator)
{
$this->requestStack = $requestStack;
- $this->fallbackLocales = $translator->getFallbackLocales();
+ $this->translator = $translator;
}
-
- /**
- * return the string in current locale if it exists.
- *
- * If it does not exists; return the name in the first language available.
- *
- * Return a blank string if any strings are available.
- * Return NULL if $translatableString is NULL
- *
- * @param array $translatableStrings
- * @return string
- */
- public function localize(array $translatableStrings)
- {
- if (NULL === $translatableStrings) {
- return NULL;
- }
-
- $language = $this->requestStack->getCurrentRequest()->getLocale();
-
- if (isset($translatableStrings[$language])) {
-
- return $translatableStrings[$language];
- } else {
- foreach ($this->fallbackLocales as $locale) {
- if (array_key_exists($locale, $translatableStrings)) {
-
- return $translatableStrings[$locale];
- }
- }
-
+ public function localize(array $translatableStrings): ?string
+ {
+ if ([] === $translatableStrings) {
+ return null;
}
-
+
+ $request = $this->requestStack->getCurrentRequest();
+
+ if (null === $request) {
+ return null;
+ }
+
+ $language = $request->getLocale();
+
+ if (array_key_exists($language, $translatableStrings)) {
+ return $translatableStrings[$language];
+ }
+
+ foreach ($this->translator->getFallbackLocales() as $locale) {
+ if (array_key_exists($locale, $translatableStrings)) {
+ return $translatableStrings[$locale];
+ }
+ }
+
// no fallback translation... trying the first available
$langs = array_keys($translatableStrings);
-
- if (count($langs) === 0) {
+
+ if ([] === $langs) {
return '';
}
-
- return $translatableStrings[$langs[0]];
+ return $translatableStrings[$langs[0]];
}
-}
\ No newline at end of file
+}
diff --git a/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelperInterface.php b/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelperInterface.php
new file mode 100644
index 000000000..72e9397f8
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelperInterface.php
@@ -0,0 +1,17 @@
+setSelectJsonbMetadata('boum')
->setSelectKey('bim')
- ->setSelectPertinence('1')
+ ->setSelectPertinence('?', ['gamma'])
->setFromClause('badaboum')
->andWhereClause('foo', [ 'alpha' ])
->andWhereClause('bar', [ 'beta' ])
@@ -21,12 +21,12 @@ class SearchApiQueryTest extends TestCase
$query = $q->buildQuery();
$this->assertStringContainsString('(foo) AND (bar)', $query);
- $this->assertEquals(['alpha', 'beta'], $q->buildParameters());
+ $this->assertEquals(['gamma', 'alpha', 'beta'], $q->buildParameters());
$query = $q->buildQuery(true);
$this->assertStringContainsString('(foo) AND (bar)', $query);
- $this->assertEquals(['alpha', 'beta'], $q->buildParameters());
+ $this->assertEquals(['gamma', 'alpha', 'beta'], $q->buildParameters());
}
public function testWithoutWhereClause()
@@ -42,4 +42,20 @@ class SearchApiQueryTest extends TestCase
$this->assertEquals([], $q->buildParameters());
}
+ public function testBuildParams()
+ {
+ $q = new SearchApiQuery();
+
+ $q
+ ->addSelectClause('bada', [ 'one', 'two' ])
+ ->addSelectClause('boum', ['three', 'four'])
+ ->setWhereClauses('mywhere', [ 'six', 'seven'])
+ ;
+
+ $params = $q->buildParameters();
+
+ $this->assertEquals(['six', 'seven'], $q->buildParameters(true));
+ $this->assertEquals(['one', 'two', 'three', 'four', 'six', 'seven'], $q->buildParameters());
+ }
+
}
diff --git a/src/Bundle/ChillMainBundle/Tests/Search/SearchProviderTest.php b/src/Bundle/ChillMainBundle/Tests/Search/SearchProviderTest.php
index 554b67b9a..99e5baed3 100644
--- a/src/Bundle/ChillMainBundle/Tests/Search/SearchProviderTest.php
+++ b/src/Bundle/ChillMainBundle/Tests/Search/SearchProviderTest.php
@@ -26,17 +26,17 @@ use PHPUnit\Framework\TestCase;
class SearchProviderTest extends TestCase
{
-
+
/**
*
- * @var SearchProvider
+ * @var SearchProvider
*/
private $search;
-
+
public function setUp()
{
$this->search = new SearchProvider();
-
+
//add a default service
$this->addSearchService(
$this->createDefaultSearchService('I am default', 10), 'default'
@@ -46,7 +46,7 @@ class SearchProviderTest extends TestCase
$this->createNonDefaultDomainSearchService('I am domain bar', 20, FALSE), 'bar'
);
}
-
+
/**
* @expectedException \Chill\MainBundle\Search\UnknowSearchNameException
*/
@@ -54,11 +54,11 @@ class SearchProviderTest extends TestCase
{
$this->search->getByName("invalid name");
}
-
+
public function testSimplePattern()
{
- $terms = $this->p("@person birthdate:2014-01-02 name:(my name) is not my name");
-
+ $terms = $this->p("@person birthdate:2014-01-02 name:\"my name\" is not my name");
+
$this->assertEquals(array(
'_domain' => 'person',
'birthdate' => '2014-01-02',
@@ -66,40 +66,40 @@ class SearchProviderTest extends TestCase
'name' => 'my name'
), $terms);
}
-
+
public function testWithoutDomain()
{
$terms = $this->p('foo:bar residual');
-
+
$this->assertEquals(array(
'_domain' => null,
'foo' => 'bar',
'_default' => 'residual'
), $terms);
}
-
+
public function testWithoutDefault()
{
$terms = $this->p('@person foo:bar');
-
+
$this->assertEquals(array(
'_domain' => 'person',
'foo' => 'bar',
'_default' => ''
), $terms);
}
-
+
public function testCapitalLetters()
{
$terms = $this->p('Foo:Bar LOL marCi @PERSON');
-
+
$this->assertEquals(array(
'_domain' => 'person',
'_default' => 'lol marci',
'foo' => 'bar'
), $terms);
}
-
+
/**
* @expectedException Chill\MainBundle\Search\ParsingException
*/
@@ -107,12 +107,11 @@ class SearchProviderTest extends TestCase
{
$term = $this->p("@person @report");
}
-
+
public function testDoubleParenthesis()
{
- $terms = $this->p("@papamobile name:(my beautiful name) residual "
- . "surname:(i love techno)");
-
+ $terms = $this->p('@papamobile name:"my beautiful name" residual surname:"i love techno"');
+
$this->assertEquals(array(
'_domain' => 'papamobile',
'name' => 'my beautiful name',
@@ -120,65 +119,65 @@ class SearchProviderTest extends TestCase
'surname' => 'i love techno'
), $terms);
}
-
+
public function testAccentued()
{
//$this->markTestSkipped('accentued characters must be implemented');
-
+
$terms = $this->p('manço bélier aztèque à saloù ê');
-
+
$this->assertEquals(array(
'_domain' => NULL,
'_default' => 'manco belier azteque a salou e'
), $terms);
}
-
+
public function testAccentuedCapitals()
{
//$this->markTestSkipped('accentued characters must be implemented');
-
+
$terms = $this->p('MANÉÀ oÛ lÎ À');
-
+
$this->assertEquals(array(
'_domain' => null,
'_default' => 'manea ou li a'
), $terms);
}
-
+
public function testTrimInParenthesis()
{
- $terms = $this->p('foo:(bar )');
-
+ $terms = $this->p('foo:"bar "');
+
$this->assertEquals(array(
'_domain' => null,
'foo' => 'bar',
'_default' => ''
), $terms);
}
-
+
public function testTrimInDefault()
{
$terms = $this->p(' foo bar ');
-
+
$this->assertEquals(array(
'_domain' => null,
'_default' => 'foo bar'
), $terms);
}
-
+
public function testArgumentNameWithTrait()
{
$terms = $this->p('date-from:2016-05-04');
-
+
$this->assertEquals(array(
'_domain' => null,
'date-from' => '2016-05-04',
'_default' => ''
), $terms);
}
-
+
/**
- * Test the behaviour when no domain is provided in the search pattern :
+ * Test the behaviour when no domain is provided in the search pattern :
* the default search should be enabled
*/
public function testSearchResultDefault()
@@ -186,12 +185,12 @@ class SearchProviderTest extends TestCase
$response = $this->search->getSearchResults('default search');
//$this->markTestSkipped();
-
+
$this->assertEquals(array(
"I am default"
- ), $response);
+ ), $response);
}
-
+
/**
* @expectedException \Chill\MainBundle\Search\UnknowSearchDomainException
*/
@@ -200,49 +199,49 @@ class SearchProviderTest extends TestCase
$response = $this->search->getSearchResults('@unknow domain');
//$this->markTestSkipped();
-
+
}
-
+
public function testSearchResultDomainSearch()
{
//add a search service which will be supported
$this->addSearchService(
$this->createNonDefaultDomainSearchService("I am domain foo", 100, TRUE), 'foo'
);
-
+
$response = $this->search->getSearchResults('@foo default search');
-
+
$this->assertEquals(array(
"I am domain foo"
), $response);
-
+
}
-
+
public function testSearchWithinSpecificSearchName()
{
//add a search service which will be supported
$this->addSearchService(
$this->createNonDefaultDomainSearchService("I am domain foo", 100, TRUE), 'foo'
);
-
+
$response = $this->search->getResultByName('@foo search', 'foo');
-
+
$this->assertEquals('I am domain foo', $response);
-
+
}
-
+
/**
* @expectedException \Chill\MainBundle\Search\ParsingException
*/
public function testSearchWithinSpecificSearchNameInConflictWithSupport()
{
$response = $this->search->getResultByName('@foo default search', 'bar');
-
+
}
-
+
/**
* shortcut for executing parse method
- *
+ *
* @param unknown $pattern
* @return string[]
*/
@@ -250,12 +249,12 @@ class SearchProviderTest extends TestCase
{
return $this->search->parse($pattern);
}
-
+
/**
* Add a search service to the chill.main.search_provider
- *
+ *
* Useful for mocking the SearchInterface
- *
+ *
* @param SearchInterface $search
* @param string $name
*/
@@ -264,52 +263,52 @@ class SearchProviderTest extends TestCase
$this->search
->addSearchService($search, $name);
}
-
+
private function createDefaultSearchService($result, $order)
{
$mock = $this
->getMockForAbstractClass('Chill\MainBundle\Search\AbstractSearch');
-
+
//set the mock as default
$mock->expects($this->any())
->method('isActiveByDefault')
->will($this->returnValue(TRUE));
-
+
$mock->expects($this->any())
->method('getOrder')
->will($this->returnValue($order));
-
+
//set the return value
$mock->expects($this->any())
->method('renderResult')
->will($this->returnValue($result));
-
+
return $mock;
}
-
+
private function createNonDefaultDomainSearchService($result, $order, $domain)
{
$mock = $this
->getMockForAbstractClass('Chill\MainBundle\Search\AbstractSearch');
-
+
//set the mock as default
$mock->expects($this->any())
->method('isActiveByDefault')
->will($this->returnValue(FALSE));
-
+
$mock->expects($this->any())
->method('getOrder')
->will($this->returnValue($order));
-
+
$mock->expects($this->any())
->method('supports')
->will($this->returnValue($domain));
-
+
//set the return value
$mock->expects($this->any())
->method('renderResult')
->will($this->returnValue($result));
-
+
return $mock;
}
}
diff --git a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php
new file mode 100644
index 000000000..428996b8e
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php
@@ -0,0 +1,45 @@
+extractDates($subject);
+
+ $this->assertCount($count, $result->getFound());
+ $this->assertEquals($filtered, $result->getFilteredSubject());
+ $this->assertContainsOnlyInstancesOf(\DateTimeImmutable::class, $result->getFound());
+
+ $dates = \array_map(
+ function (\DateTimeImmutable $d) {
+ return $d->format('Y-m-d');
+ }, $result->getFound()
+ );
+
+ foreach ($datesSearched as $date) {
+ $this->assertContains($date, $dates);
+ }
+ }
+
+ public function provideSubjects()
+ {
+ yield ["15/06/1981", "", 1, '1981-06-15'];
+ yield ["15/06/1981 30/12/1987", "", 2, '1981-06-15', '1987-12-30'];
+ yield ["diallo 15/06/1981", "diallo", 1, '1981-06-15'];
+ yield ["diallo 31/03/1981", "diallo", 1, '1981-03-31'];
+ yield ["diallo 15-06-1981", "diallo", 1, '1981-06-15'];
+ yield ["diallo 1981-12-08", "diallo", 1, '1981-12-08'];
+ yield ["diallo", "diallo", 0];
+ }
+
+}
diff --git a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractPhonenumberFromPatternTest.php b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractPhonenumberFromPatternTest.php
new file mode 100644
index 000000000..5c88efa7e
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractPhonenumberFromPatternTest.php
@@ -0,0 +1,33 @@
+extractPhonenumber($subject);
+
+ $this->assertCount($expectedCount, $result->getFound());
+ $this->assertEquals($filteredSubject, $result->getFilteredSubject());
+ $this->assertEquals($expected, $result->getFound());
+ }
+
+ public function provideData()
+ {
+ yield ['Diallo', 0, [], 'Diallo', "no phonenumber"];
+ yield ['Diallo 15/06/2021', 0, [], 'Diallo 15/06/2021', "no phonenumber and a date"];
+ yield ['Diallo 0486 123 456', 1, ['+32486123456'], 'Diallo', "a phonenumber and a name"];
+ yield ['Diallo 123 456', 1, ['123456'], 'Diallo', "a number and a name, without leadiing 0"];
+ yield ['123 456', 1, ['123456'], '', "only phonenumber"];
+ yield ['0123 456', 1, ['+32123456'], '', "only phonenumber with a leading 0"];
+ }
+
+}
diff --git a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DateNormalizerTest.php b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DateNormalizerTest.php
new file mode 100644
index 000000000..03e3015e8
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DateNormalizerTest.php
@@ -0,0 +1,88 @@
+prophet = new Prophet();
+ }
+
+ public function testSupports()
+ {
+ $this->assertTrue($this->buildDateNormalizer()->supportsNormalization(new \DateTime(), 'json'));
+ $this->assertTrue($this->buildDateNormalizer()->supportsNormalization(new \DateTimeImmutable(), 'json'));
+ $this->assertTrue($this->buildDateNormalizer()->supportsNormalization(new \DateTime(), 'docgen'));
+ $this->assertTrue($this->buildDateNormalizer()->supportsNormalization(new \DateTimeImmutable(), 'docgen'));
+ $this->assertTrue($this->buildDateNormalizer()->supportsNormalization(null, 'docgen', ['docgen:expects' => \DateTimeImmutable::class]));
+ $this->assertTrue($this->buildDateNormalizer()->supportsNormalization(null, 'docgen', ['docgen:expects' => \DateTimeInterface::class]));
+ $this->assertTrue($this->buildDateNormalizer()->supportsNormalization(null, 'docgen', ['docgen:expects' => \DateTime::class]));
+ $this->assertFalse($this->buildDateNormalizer()->supportsNormalization(new \stdClass(), 'docgen'));
+ $this->assertFalse($this->buildDateNormalizer()->supportsNormalization(new \DateTime(), 'xml'));
+ }
+
+ /**
+ * @dataProvider generateDataNormalize
+ */
+ public function testNormalize($expected, $date, $format, $locale, $msg)
+ {
+ $this->assertEquals($expected, $this->buildDateNormalizer($locale)->normalize($date, $format, []), $msg);
+ }
+
+ private function buildDateNormalizer(string $locale = null): DateNormalizer
+ {
+ $requestStack = $this->prophet->prophesize(RequestStack::class);
+ $parameterBag = new ParameterBag();
+ $parameterBag->set('kernel.default_locale', 'fr');
+
+ if ($locale === null) {
+ $requestStack->getCurrentRequest()->willReturn(null);
+ } else {
+ $request = $this->prophet->prophesize(Request::class);
+ $request->getLocale()->willReturn($locale);
+ $requestStack->getCurrentRequest()->willReturn($request->reveal());
+ }
+
+ return new DateNormalizer($requestStack->reveal(), $parameterBag);
+ }
+
+ public function generateDataNormalize()
+ {
+ $datetime = \DateTime::createFromFormat('Y-m-d H:i:sO', '2021-06-05 15:05:01+02:00');
+ $date = \DateTime::createFromFormat('Y-m-d H:i:sO', '2021-06-05 00:00:00+02:00');
+ yield [
+ ['datetime' => '2021-06-05T15:05:01+0200'],
+ $datetime, 'json', null, 'simple normalization to json'
+ ];
+
+ yield [
+ ['long' => '5 juin 2021', 'short' => '05/06/2021'],
+ $date, 'docgen', 'fr', 'normalization to docgen for a date, with current request'
+ ];
+
+ yield [
+ ['long' => '5 juin 2021', 'short' => '05/06/2021'],
+ $date, 'docgen', null, 'normalization to docgen for a date, without current request'
+ ];
+
+ yield [
+ ['long' => '5 juin 2021 à 15:05', 'short' => '05/06/2021 15:05'],
+ $datetime, 'docgen', null, 'normalization to docgen for a datetime, without current request'
+ ];
+
+ yield [
+ ['long' => '', 'short' => ''],
+ null, 'docgen', null, 'normalization to docgen for a null datetime'
+ ];
+ }
+}
diff --git a/src/Bundle/ChillMainBundle/config/services.yaml b/src/Bundle/ChillMainBundle/config/services.yaml
index f5f10cf57..dd098c75d 100644
--- a/src/Bundle/ChillMainBundle/config/services.yaml
+++ b/src/Bundle/ChillMainBundle/config/services.yaml
@@ -8,38 +8,29 @@ services:
Chill\MainBundle\Repository\:
resource: '../Repository/'
- autowire: true
- autoconfigure: true
Chill\MainBundle\Repository\UserACLAwareRepositoryInterface: '@Chill\MainBundle\Repository\UserACLAwareRepository'
Chill\MainBundle\Serializer\Normalizer\:
resource: '../Serializer/Normalizer'
- autoconfigure: true
- autowire: true
tags:
- { name: 'serializer.normalizer', priority: 64 }
Chill\MainBundle\Form\Type\:
resource: '../Form/Type'
- autoconfigure: true
- autowire: true
tags:
- { name: form.type }
Chill\MainBundle\Doctrine\Event\:
resource: '../Doctrine/Event/'
- autowire: true
tags:
- { name: 'doctrine.event_subscriber' }
chill.main.helper.translatable_string:
class: Chill\MainBundle\Templating\TranslatableStringHelper
- arguments:
- - "@request_stack"
- - "@translator.default"
Chill\MainBundle\Templating\TranslatableStringHelper: '@chill.main.helper.translatable_string'
+ Chill\MainBundle\Templating\TranslatableStringHelperInterface: '@Chill\MainBundle\Templating\TranslatableStringHelper'
chill.main.twig.translatable_string:
class: Chill\MainBundle\Templating\TranslatableStringTwig
diff --git a/src/Bundle/ChillMainBundle/config/services/cache.yaml b/src/Bundle/ChillMainBundle/config/services/cache.yaml
index de362ea30..ce2bb3e08 100644
--- a/src/Bundle/ChillMainBundle/config/services/cache.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/cache.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill_main.tag_aware_cache:
class: Symfony\Component\Cache\Adapter\TagAwareAdapter
arguments:
diff --git a/src/Bundle/ChillMainBundle/config/services/command.yaml b/src/Bundle/ChillMainBundle/config/services/command.yaml
index 5df80c2ad..87220bc1f 100644
--- a/src/Bundle/ChillMainBundle/config/services/command.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/command.yaml
@@ -1,10 +1,9 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Command\ChillImportUsersCommand:
- arguments:
- $em: '@Doctrine\ORM\EntityManagerInterface'
- $logger: '@Psr\Log\LoggerInterface'
- $passwordEncoder: '@Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface'
- $validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
tags:
- { name: console.command }
diff --git a/src/Bundle/ChillMainBundle/config/services/controller.yaml b/src/Bundle/ChillMainBundle/config/services/controller.yaml
index a74755ffd..28abc94e8 100644
--- a/src/Bundle/ChillMainBundle/config/services/controller.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/controller.yaml
@@ -1,12 +1,13 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
Chill\MainBundle\Controller\:
- autowire: true
resource: '../../Controller'
tags: ['controller.service_arguments']
Chill\MainBundle\Controller\PasswordController:
- autowire: true
arguments:
$chillLogger: '@monolog.logger.chill'
tags: ['controller.service_arguments']
@@ -28,10 +29,6 @@ services:
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
tags: ['controller.service_arguments']
- Chill\MainBundle\Controller\UserController:
- autowire: true
- autoconfigure: true
-
Chill\MainBundle\Controller\NotificationController:
arguments:
$security: '@Symfony\Component\Security\Core\Security'
diff --git a/src/Bundle/ChillMainBundle/config/services/crud.yaml b/src/Bundle/ChillMainBundle/config/services/crud.yaml
index 5d1940a87..02533f433 100644
--- a/src/Bundle/ChillMainBundle/config/services/crud.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/crud.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\CRUD\Routing\CRUDRoutesLoader:
arguments:
$crudConfig: '%chill_main_crud_route_loader_config%'
diff --git a/src/Bundle/ChillMainBundle/config/services/doctrine.yaml b/src/Bundle/ChillMainBundle/config/services/doctrine.yaml
index 09b68f03b..e59088fc4 100644
--- a/src/Bundle/ChillMainBundle/config/services/doctrine.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/doctrine.yaml
@@ -1,3 +1,7 @@
---
services:
- 'Chill\MainBundle\Doctrine\Migrations\VersionComparator': ~
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
+ Chill\MainBundle\Doctrine\Migrations\VersionComparator: ~
diff --git a/src/Bundle/ChillMainBundle/config/services/export.yaml b/src/Bundle/ChillMainBundle/config/services/export.yaml
index ac49199af..ce361677b 100644
--- a/src/Bundle/ChillMainBundle/config/services/export.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/export.yaml
@@ -1,9 +1,13 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill.main.export_element_validator:
class: Chill\MainBundle\Validator\Constraints\Export\ExportElementConstraintValidator
tags:
- { name: validator.constraint_validator }
-
+
# deprecated in favor of spreadsheet_formatter
# chill.main.export.csv_formatter:
# class: Chill\MainBundle\Export\Formatter\CSVFormatter
@@ -11,7 +15,7 @@ services:
# - "@translator"
# tags:
# - { name: chill.export_formatter, alias: 'csv' }
-
+
chill.main.export.spreadsheet_formatter:
class: Chill\MainBundle\Export\Formatter\SpreadSheetFormatter
arguments:
@@ -19,7 +23,7 @@ services:
$exportManager: '@Chill\MainBundle\Export\ExportManager'
tags:
- { name: chill.export_formatter, alias: 'spreadsheet' }
-
+
chill.main.export.list_formatter:
class: Chill\MainBundle\Export\Formatter\CSVListFormatter
arguments:
@@ -27,7 +31,7 @@ services:
$exportManager: '@Chill\MainBundle\Export\ExportManager'
tags:
- { name: chill.export_formatter, alias: 'csvlist' }
-
+
chill.main.export.list_spreadsheet_formatter:
class: Chill\MainBundle\Export\Formatter\SpreadsheetListFormatter
arguments:
@@ -35,7 +39,7 @@ services:
$exportManager: '@Chill\MainBundle\Export\ExportManager'
tags:
- { name: chill.export_formatter, alias: 'spreadlist' }
-
+
chill.main.export.pivoted_list_formatter:
class: Chill\MainBundle\Export\Formatter\CSVPivotedListFormatter
arguments:
@@ -43,4 +47,3 @@ services:
$exportManager: '@Chill\MainBundle\Export\ExportManager'
tags:
- { name: chill.export_formatter, alias: 'csv_pivoted_list' }
-
\ No newline at end of file
diff --git a/src/Bundle/ChillMainBundle/config/services/fixtures.yaml b/src/Bundle/ChillMainBundle/config/services/fixtures.yaml
index ccae65867..29aabb25f 100644
--- a/src/Bundle/ChillMainBundle/config/services/fixtures.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/fixtures.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\DataFixtures\ORM\:
resource: ../../DataFixtures/ORM
tags: [ 'doctrine.fixture.orm' ]
diff --git a/src/Bundle/ChillMainBundle/config/services/form.yaml b/src/Bundle/ChillMainBundle/config/services/form.yaml
index 8c741ed36..0d0a17201 100644
--- a/src/Bundle/ChillMainBundle/config/services/form.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/form.yaml
@@ -1,4 +1,7 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
chill.main.form.type.translatable.string:
class: Chill\MainBundle\Form\Type\TranslatableStringFormType
@@ -39,9 +42,7 @@ services:
tags:
- { name: form.type, alias: select2_chill_language }
- Chill\MainBundle\Form\Type\PickCenterType:
- autowire: true
- autoconfigure: true
+ Chill\MainBundle\Form\Type\PickCenterType: ~
chill.main.form.type.composed_role_scope:
class: Chill\MainBundle\Form\Type\ComposedRoleScopeType
@@ -62,9 +63,7 @@ services:
tags:
- { name: form.type }
- Chill\MainBundle\Form\ChoiceLoader\PostalCodeChoiceLoader:
- autowire: true
- autoconfigure: true
+ Chill\MainBundle\Form\ChoiceLoader\PostalCodeChoiceLoader: ~
chill.main.form.type.export:
class: Chill\MainBundle\Form\Type\Export\ExportType
@@ -96,14 +95,10 @@ services:
arguments:
- '@Chill\MainBundle\Export\ExportManager'
- Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer:
- autowire: true
- autoconfigure: true
+ Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer: ~
chill.main.form.advanced_search_type:
class: Chill\MainBundle\Form\AdvancedSearchType
- autowire: true
- autoconfigure: true
arguments:
- "@chill_main.search_provider"
tags:
@@ -116,9 +111,7 @@ services:
tags:
- { name: form.type }
- Chill\MainBundle\Form\UserType:
- autowire: true
- autoconfigure: true
+ Chill\MainBundle\Form\UserType: ~
Chill\MainBundle\Form\PermissionsGroupType:
tags:
@@ -131,10 +124,9 @@ services:
tags:
- { name: form.type }
+ Chill\MainBundle\Form\Type\PickAddressType: ~
- Chill\MainBundle\Form\Type\PickAddressType:
- autoconfigure: true
- autowire: true
+ Chill\MainBundle\Form\DataTransform\AddressToIdDataTransformer: ~
Chill\MainBundle\Form\DataTransform\AddressToIdDataTransformer:
autoconfigure: true
@@ -147,3 +139,5 @@ services:
Chill\MainBundle\Form\UserCurrentLocationType:
autowire: true
autoconfigure: true
+
+ Chill\MainBundle\Form\Type\LocationFormType: ~
diff --git a/src/Bundle/ChillMainBundle/config/services/logger.yaml b/src/Bundle/ChillMainBundle/config/services/logger.yaml
index 2da5a4a4c..a8c8dce58 100644
--- a/src/Bundle/ChillMainBundle/config/services/logger.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/logger.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill.main.logger:
# a logger to log events from the app (deletion, remove, etc.)
alias: monolog.logger.chill
diff --git a/src/Bundle/ChillMainBundle/config/services/menu.yaml b/src/Bundle/ChillMainBundle/config/services/menu.yaml
index cf31dccf1..a41e90345 100644
--- a/src/Bundle/ChillMainBundle/config/services/menu.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/menu.yaml
@@ -1,9 +1,11 @@
services:
- Chill\MainBundle\Routing\MenuBuilder\:
- resource: '../../Routing/MenuBuilder'
+ _defaults:
autowire: true
autoconfigure: true
+ Chill\MainBundle\Routing\MenuBuilder\:
+ resource: '../../Routing/MenuBuilder'
+
Chill\MainBundle\Routing\MenuBuilder\UserMenuBuilder:
arguments:
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
diff --git a/src/Bundle/ChillMainBundle/config/services/notification.yaml b/src/Bundle/ChillMainBundle/config/services/notification.yaml
index c8d970c5d..efb25c5b5 100644
--- a/src/Bundle/ChillMainBundle/config/services/notification.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/notification.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Notification\Mailer:
arguments:
$logger: '@Psr\Log\LoggerInterface'
@@ -9,6 +13,4 @@ services:
$translator: '@Symfony\Component\Translation\TranslatorInterface'
$routeParameters: '%chill_main.notifications%'
- Chill\MainBundle\Notification\NotificationRenderer:
- autoconfigure: true
- autowire: true
+ Chill\MainBundle\Notification\NotificationRenderer: ~
diff --git a/src/Bundle/ChillMainBundle/config/services/pagination.yaml b/src/Bundle/ChillMainBundle/config/services/pagination.yaml
index cb0855a3d..f94bc31be 100644
--- a/src/Bundle/ChillMainBundle/config/services/pagination.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/pagination.yaml
@@ -1,9 +1,11 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill_main.paginator_factory:
class: Chill\MainBundle\Pagination\PaginatorFactory
public: true
- autowire: true
- autoconfigure: true
arguments:
- "@request_stack"
- "@router"
diff --git a/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml b/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml
index f297c03e0..46fa853ee 100644
--- a/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml
@@ -1,19 +1,21 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Phonenumber\PhonenumberHelper:
arguments:
- $logger: '@Psr\Log\LoggerInterface'
$config: '%chill_main.phone_helper%'
$cachePool: '@cache.user_data'
-
+
Chill\MainBundle\Phonenumber\Templating:
arguments:
$phonenumberHelper: '@Chill\MainBundle\Phonenumber\PhonenumberHelper'
tags:
- { name: twig.extension }
-
+
Chill\MainBundle\Validation\Validator\ValidPhonenumber:
arguments:
- $logger: '@Psr\Log\LoggerInterface'
$phonenumberHelper: '@Chill\MainBundle\Phonenumber\PhonenumberHelper'
tags:
- { name: validator.constraint_validator }
diff --git a/src/Bundle/ChillMainBundle/config/services/redis.yaml b/src/Bundle/ChillMainBundle/config/services/redis.yaml
index c8d5c2879..6ccbfee7f 100644
--- a/src/Bundle/ChillMainBundle/config/services/redis.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/redis.yaml
@@ -1,10 +1,13 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Redis\RedisConnectionFactory:
arguments:
$parameters: "%chill_main.redis%"
tags:
- { name: kernel.event_subcriber }
-
+
Chill\MainBundle\Redis\ChillRedis:
factory: [ '@Chill\MainBundle\Redis\RedisConnectionFactory', 'create' ]
-
\ No newline at end of file
diff --git a/src/Bundle/ChillMainBundle/config/services/routing.yaml b/src/Bundle/ChillMainBundle/config/services/routing.yaml
index c935f1a4d..fa8a56696 100644
--- a/src/Bundle/ChillMainBundle/config/services/routing.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/routing.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill.main.menu_composer:
class: Chill\MainBundle\Routing\MenuComposer
arguments:
@@ -6,7 +10,7 @@ services:
- '@Knp\Menu\FactoryInterface'
- '@Symfony\Component\Translation\TranslatorInterface'
Chill\MainBundle\Routing\MenuComposer: '@chill.main.menu_composer'
-
+
chill.main.routes_loader:
class: Chill\MainBundle\Routing\Loader\ChillRoutesLoader
arguments:
diff --git a/src/Bundle/ChillMainBundle/config/services/search.yaml b/src/Bundle/ChillMainBundle/config/services/search.yaml
index 38e421eaf..91cfb120b 100644
--- a/src/Bundle/ChillMainBundle/config/services/search.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/search.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill_main.search_provider:
class: Chill\MainBundle\Search\SearchProvider
@@ -7,8 +11,13 @@ services:
Chill\MainBundle\Search\SearchApi:
autowire: true
autoconfigure: true
+ arguments:
+ $providers: !tagged_iterator chill.search_api_provider
Chill\MainBundle\Search\Entity\:
+ resource: '../../Search/Entity'
+
+ Chill\MainBundle\Search\Utils\:
autowire: true
autoconfigure: true
- resource: '../../Search/Entity'
+ resource: './../Search/Utils/'
diff --git a/src/Bundle/ChillMainBundle/config/services/security.yaml b/src/Bundle/ChillMainBundle/config/services/security.yaml
index dc7949556..163b86d8e 100644
--- a/src/Bundle/ChillMainBundle/config/services/security.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/security.yaml
@@ -3,46 +3,35 @@ services:
autowire: true
autoconfigure: true
- # do not autowire the directory Security/Resolver
Chill\MainBundle\Security\Resolver\CenterResolverDispatcher:
arguments:
- !tagged_iterator chill_main.center_resolver
+ Chill\MainBundle\Security\Resolver\CenterResolverManager:
+ arguments:
+ - !tagged_iterator chill_main.center_resolver
+ Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface: '@Chill\MainBundle\Security\Resolver\CenterResolverManager'
+
Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher:
arguments:
- !tagged_iterator chill_main.scope_resolver
- # do not autowire the directory Security/Resolver
- Chill\MainBundle\Security\Resolver\DefaultCenterResolver:
- autoconfigure: true
- autowire: true
+ Chill\MainBundle\Security\Resolver\DefaultCenterResolver: ~
- Chill\MainBundle\Security\Resolver\DefaultScopeResolver:
- autoconfigure: true
- autowire: true
+ Chill\MainBundle\Security\Resolver\DefaultScopeResolver: ~
- # do not autowire the directory Security/Resolver
- Chill\MainBundle\Security\Resolver\ResolverTwigExtension:
- autoconfigure: true
- autowire: true
+ Chill\MainBundle\Security\Resolver\ResolverTwigExtension: ~
- # do not autowire the directory Security/Resolver
- Chill\MainBundle\Security\Authorization\DefaultVoterHelperFactory:
- autowire: true
+ Chill\MainBundle\Security\Authorization\DefaultVoterHelperFactory: ~
- # do not autowire the directory Security/Resolver
Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface: '@Chill\MainBundle\Security\Authorization\DefaultVoterHelperFactory'
chill.main.security.authorization.helper:
class: Chill\MainBundle\Security\Authorization\AuthorizationHelper
- autowire: true
- autoconfigure: true
Chill\MainBundle\Security\Authorization\AuthorizationHelper: '@chill.main.security.authorization.helper'
Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface: '@chill.main.security.authorization.helper'
- Chill\MainBundle\Security\ParentRoleHelper:
- autowire: true
- autoconfigure: true
+ Chill\MainBundle\Security\ParentRoleHelper: ~
chill.main.role_provider:
class: Chill\MainBundle\Security\RoleProvider
@@ -54,20 +43,16 @@ services:
Symfony\Component\Security\Core\User\UserProviderInterface: "@chill.main.user_provider"
Chill\MainBundle\Security\Authorization\ChillExportVoter:
- arguments:
- $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
tags:
- { name: security.voter }
Chill\MainBundle\Security\PasswordRecover\TokenManager:
arguments:
$secret: '%kernel.secret%'
- $logger: '@Psr\Log\LoggerInterface'
Chill\MainBundle\Security\PasswordRecover\RecoverPasswordHelper:
arguments:
$tokenManager: '@Chill\MainBundle\Security\PasswordRecover\TokenManager'
- $urlGenerator: '@Symfony\Component\Routing\Generator\UrlGeneratorInterface'
$mailer: '@Chill\MainBundle\Notification\Mailer'
$routeParameters: "%chill_main.notifications%"
@@ -80,11 +65,9 @@ services:
Chill\MainBundle\Security\PasswordRecover\PasswordRecoverLocker:
arguments:
$chillRedis: '@Chill\MainBundle\Redis\ChillRedis'
- $logger: '@Psr\Log\LoggerInterface'
Chill\MainBundle\Security\PasswordRecover\PasswordRecoverVoter:
arguments:
$locker: '@Chill\MainBundle\Security\PasswordRecover\PasswordRecoverLocker'
- $requestStack: '@Symfony\Component\HttpFoundation\RequestStack'
tags:
- { name: security.voter }
diff --git a/src/Bundle/ChillMainBundle/config/services/serializer.yaml b/src/Bundle/ChillMainBundle/config/services/serializer.yaml
index efe98996e..4d8aa9954 100644
--- a/src/Bundle/ChillMainBundle/config/services/serializer.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/serializer.yaml
@@ -1,11 +1,13 @@
---
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
# note: the autowiring for serializers and normalizers is declared
# into ../services.yaml
Chill\MainBundle\Serializer\Normalizer\DoctrineExistingEntityNormalizer:
- autowire: true
tags:
- { name: 'serializer.normalizer', priority: 8 }
diff --git a/src/Bundle/ChillMainBundle/config/services/templating.yaml b/src/Bundle/ChillMainBundle/config/services/templating.yaml
index 02d806db4..ade26b946 100644
--- a/src/Bundle/ChillMainBundle/config/services/templating.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/templating.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
# twig_intl:
# class: Twig_Extensions_Extension_Intl
# tags:
@@ -32,8 +36,6 @@ services:
- { name: twig.extension }
Chill\MainBundle\Templating\Entity\CommentRender:
- autoconfigure: true
- autowire: true
tags:
- { name: 'chill.render_entity' }
@@ -41,17 +43,11 @@ services:
tags:
- { name: twig.extension }
- Chill\MainBundle\Templating\Entity\AddressRender:
- autoconfigure: true
- autowire: true
+ Chill\MainBundle\Templating\Entity\AddressRender: ~
- Chill\MainBundle\Templating\Entity\UserRender:
- autoconfigure: true
- autowire: true
+ Chill\MainBundle\Templating\Entity\UserRender: ~
Chill\MainBundle\Templating\Listing\:
resource: './../../Templating/Listing'
- autoconfigure: true
- autowire: true
Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface: '@Chill\MainBundle\Templating\Listing\FilterOrderHelperFactory'
diff --git a/src/Bundle/ChillMainBundle/config/services/timeline.yaml b/src/Bundle/ChillMainBundle/config/services/timeline.yaml
index fe830c7ab..7b7987f5a 100644
--- a/src/Bundle/ChillMainBundle/config/services/timeline.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/timeline.yaml
@@ -1,4 +1,8 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill_main.timeline_builder:
class: Chill\MainBundle\Timeline\TimelineBuilder
arguments:
diff --git a/src/Bundle/ChillMainBundle/config/services/validator.yaml b/src/Bundle/ChillMainBundle/config/services/validator.yaml
index c15b2181e..b3b60b9d6 100644
--- a/src/Bundle/ChillMainBundle/config/services/validator.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/validator.yaml
@@ -1,11 +1,15 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
chill_main.validator_user_circle_consistency:
class: Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistencyValidator
arguments:
- "@chill.main.security.authorization.helper"
tags:
- { name: "validator.constraint_validator" }
-
+
Chill\MainBundle\Validation\Validator\UserUniqueEmailAndUsername:
arguments:
$em: '@Doctrine\ORM\EntityManagerInterface'
diff --git a/src/Bundle/ChillMainBundle/config/services/widget.yaml b/src/Bundle/ChillMainBundle/config/services/widget.yaml
index 53f29da5b..1f4bca2e3 100644
--- a/src/Bundle/ChillMainBundle/config/services/widget.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/widget.yaml
@@ -1,2 +1,6 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
Chill\MainBundle\Templating\UI\CountNotificationUser: ~
diff --git a/src/Bundle/ChillMainBundle/migrations/Version20211119173554.php b/src/Bundle/ChillMainBundle/migrations/Version20211119173554.php
new file mode 100644
index 000000000..d8f705f39
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/migrations/Version20211119173554.php
@@ -0,0 +1,35 @@
+addSql("COMMENT ON COLUMN $col IS NULL");
+ }
+ }
+
+ public function down(Schema $schema): void
+ {
+ $this->throwIrreversibleMigrationException();
+ }
+}
diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml
index a4d49403d..fcd31ce72 100644
--- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml
+++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml
@@ -86,6 +86,10 @@ address more:
Create a new address: Créer une nouvelle adresse
Create an address: Créer une adresse
Update address: Modifier l'adresse
+City or postal code: Ville ou code postal
+
+# contact
+Part of the phonenumber: Partie du numéro de téléphone
#serach
Your search is empty. Please provide search terms.: La recherche est vide. Merci de fournir des termes de recherche.
@@ -196,7 +200,7 @@ Location: Localisation
Location type list: Liste des types de localisation
Create a new location type: Créer un nouveau type de localisation
Available for users: Disponible aux utilisateurs
-Address required: Adresse requise?
+Address required: Adresse requise?
Contact data: Données de contact?
optional: optionnel
required: requis
diff --git a/src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php b/src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php
index 4e3d67755..389c723ce 100644
--- a/src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php
@@ -1,87 +1,62 @@
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
+declare(strict_types=1);
namespace Chill\PersonBundle\Controller;
+use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
+use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Privacy\PrivacyEvent;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Chill\MainBundle\Timeline\TimelineBuilder;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
-use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
-use Symfony\Component\Security\Core\Role\Role;
class TimelinePersonController extends AbstractController
{
-
protected EventDispatcherInterface $eventDispatcher;
-
+
protected TimelineBuilder $timelineBuilder;
-
+
protected PaginatorFactory $paginatorFactory;
-
- /**
- * TimelinePersonController constructor.
- *
- * @param EventDispatcherInterface $eventDispatcher
- */
+
public function __construct(
EventDispatcherInterface $eventDispatcher,
TimelineBuilder $timelineBuilder,
- PaginatorFactory $paginatorFactory,
- AuthorizationHelper $authorizationHelper
+ PaginatorFactory $paginatorFactory
) {
$this->eventDispatcher = $eventDispatcher;
$this->timelineBuilder = $timelineBuilder;
$this->paginatorFactory = $paginatorFactory;
- $this->authorizationHelper = $authorizationHelper;
}
-
-
+
public function personAction(Request $request, $person_id)
{
$person = $this->getDoctrine()
- ->getRepository('ChillPersonBundle:Person')
+ ->getRepository(Person::class)
->find($person_id);
if ($person === NULL) {
throw $this->createNotFoundException();
}
-
+
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
-
- $nbItems = $this->timelineBuilder->countItems('person',
+
+ $nbItems = $this->timelineBuilder->countItems('person',
[ 'person' => $person ]
);
-
+
$paginator = $this->paginatorFactory->create($nbItems);
-
+
$event = new PrivacyEvent($person, array('action' => 'timeline'));
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
-
+
return $this->render('ChillPersonBundle:Timeline:index.html.twig', array
(
'timeline' => $this->timelineBuilder->getTimelineHTML(
- 'person',
+ 'person',
array('person' => $person),
$paginator->getCurrentPage()->getFirstItemNumber(),
$paginator->getItemsPerPage()
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/Helper/RandomPersonHelperTrait.php b/src/Bundle/ChillPersonBundle/DataFixtures/Helper/RandomPersonHelperTrait.php
new file mode 100644
index 000000000..c6cef7aa0
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/Helper/RandomPersonHelperTrait.php
@@ -0,0 +1,35 @@
+createQueryBuilder();
+ $qb
+ ->from(Person::class, 'p')
+ ;
+
+ if (null === $this->nbOfPersons) {
+ $this->nbOfPersons = $qb
+ ->select('COUNT(p)')
+ ->getQuery()
+ ->getSingleScalarResult()
+ ;
+ }
+
+ return $qb
+ ->select('p')
+ ->setMaxResults(1)
+ ->setFirstResult(\random_int(0, $this->nbOfPersons))
+ ->getQuery()
+ ->getSingleResult()
+ ;
+ }
+}
diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php
index 14420ed88..50bf94e58 100644
--- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php
+++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php
@@ -1,5 +1,7 @@
editorFactory = $editorFactory;
@@ -149,14 +153,14 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
private function preparePersonIds()
{
+ // @TODO: Remove this and make this service stateless
$this->personIds = $this->em
->createQuery('SELECT p.id FROM '.Person::class.' p '.
'JOIN p.center c '.
'WHERE c.name = :center '
)
->setParameter('center', 'Center A')
- ->getScalarResult()
- ;
+ ->getScalarResult();
\shuffle($this->personIds);
}
@@ -169,9 +173,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
for ($i=0; $i < $nb; $i++) {
$personId = \array_pop($this->personIds)['id'];
- $persons[] = $this->em->getRepository(Person::class)
- ->find($personId)
- ;
+ $persons[] = $this->em->getRepository(Person::class)->find($personId);
}
return $persons;
diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php
index 211765330..ce4169741 100644
--- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php
+++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php
@@ -86,13 +86,6 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
$loader->load('services/security.yaml');
$loader->load('services/doctrineEventListener.yaml');
- // load service advanced search only if configure
- if ($config['search']['search_by_phone'] != 'never') {
- $loader->load('services/search_by_phone.yaml');
- $container->setParameter('chill_person.search.search_by_phone',
- $config['search']['search_by_phone']);
- }
-
if ($container->getParameter('chill_person.accompanying_period') !== 'hidden') {
$loader->load('services/exports_accompanying_period.yaml');
}
diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php
index 2c53af0fe..4e42e3137 100644
--- a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php
+++ b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php
@@ -27,19 +27,6 @@ class Configuration implements ConfigurationInterface
$rootNode
->canBeDisabled()
->children()
- ->arrayNode('search')
- ->canBeDisabled()
- ->children()
- ->enumNode('search_by_phone')
- ->values(['always', 'on-domain', 'never'])
- ->defaultValue('on-domain')
- ->info('enable search by phone. \'always\' show the result '
- . 'on every result. \'on-domain\' will show the result '
- . 'only if the domain is given in the search box. '
- . '\'never\' disable this feature')
- ->end()
- ->end() //children for 'search', parent = array node 'search'
- ->end() // array 'search', parent = children of root
->arrayNode('validation')
->canBeDisabled()
->children()
diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
index 15f33abe7..74c7be856 100644
--- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
+++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
@@ -1139,11 +1139,11 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
public function getGroupSequence()
{
- if ($this->getStep() == self::STEP_DRAFT) {
+ if ($this->getStep() == self::STEP_DRAFT)
+ {
return [[self::STEP_DRAFT]];
- }
-
- if ($this->getStep() == self::STEP_CONFIRMED) {
+ } elseif ($this->getStep() == self::STEP_CONFIRMED)
+ {
return [[self::STEP_DRAFT, self::STEP_CONFIRMED]];
}
diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php
index 7ff90b652..cc497aeca 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php
@@ -434,6 +434,5 @@ class Household
->addViolation();
}
}
- dump($cond);
}
}
diff --git a/src/Bundle/ChillPersonBundle/Entity/MaritalStatus.php b/src/Bundle/ChillPersonBundle/Entity/MaritalStatus.php
index 67185c36a..afca96370 100644
--- a/src/Bundle/ChillPersonBundle/Entity/MaritalStatus.php
+++ b/src/Bundle/ChillPersonBundle/Entity/MaritalStatus.php
@@ -37,20 +37,20 @@ class MaritalStatus
* @ORM\Id()
* @ORM\Column(type="string", length=7)
*/
- private $id;
+ private ?string $id;
/**
* @var string array
* @ORM\Column(type="json")
*/
- private $name;
+ private array $name;
/**
* Get id
*
* @return string
*/
- public function getId()
+ public function getId(): string
{
return $this->id;
}
@@ -61,7 +61,7 @@ class MaritalStatus
* @param string $id
* @return MaritalStatus
*/
- public function setId($id)
+ public function setId(string $id): self
{
$this->id = $id;
return $this;
@@ -73,7 +73,7 @@ class MaritalStatus
* @param string array $name
* @return MaritalStatus
*/
- public function setName($name)
+ public function setName(array $name): self
{
$this->name = $name;
@@ -85,7 +85,7 @@ class MaritalStatus
*
* @return string array
*/
- public function getName()
+ public function getName(): array
{
return $this->name;
}
diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php
index e17bd5ceb..a7e8fec68 100644
--- a/src/Bundle/ChillPersonBundle/Entity/Person.php
+++ b/src/Bundle/ChillPersonBundle/Entity/Person.php
@@ -39,10 +39,16 @@ use DateTimeInterface;
*
* @ORM\Entity
* @ORM\Table(name="chill_person_person",
- * indexes={@ORM\Index(
+ * indexes={
+ * @ORM\Index(
* name="person_names",
* columns={"firstName", "lastName"}
- * )})
+ * ),
+ * @ORM\Index(
+ * name="person_birthdate",
+ * columns={"birthdate"}
+ * )
+ * })
* @ORM\HasLifecycleCallbacks()
* @DiscriminatorMap(typeProperty="type", mapping={
* "person"=Person::class
@@ -63,7 +69,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
- private int $id;
+ private ?int $id = null;
/**
* The person's first name
@@ -213,7 +219,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* groups={"general", "creation"}
* )
*/
- private ?\DateTime $maritalStatusDate;
+ private ?\DateTime $maritalStatusDate = null;
/**
* Comment on marital status
@@ -246,7 +252,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* The person's phonenumber
* @var string
*
- * @ORM\Column(type="text", length=40, nullable=true)
+ * @ORM\Column(type="text")
* @Assert\Regex(
* pattern="/^([\+{1}])([0-9\s*]{4,20})$/",
* groups={"general", "creation"}
@@ -256,13 +262,13 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* groups={"general", "creation"}
* )
*/
- private $phonenumber = '';
+ private string $phonenumber = '';
/**
* The person's mobile phone number
* @var string
*
- * @ORM\Column(type="text", length=40, nullable=true)
+ * @ORM\Column(type="text")
* @Assert\Regex(
* pattern="/^([\+{1}])([0-9\s*]{4,20})$/",
* groups={"general", "creation"}
@@ -272,7 +278,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* groups={"general", "creation"}
* )
*/
- private $mobilenumber = '';
+ private string $mobilenumber = '';
/**
* @var Collection
@@ -305,11 +311,10 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* The person's center
- * @var Center
*
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Center")
*/
- private $center;
+ private ?Center $center = null;
/**
* The person's accompanying periods (when the person was accompanied by the center)
@@ -713,7 +718,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return false;
}
- public function getId(): int
+ public function getId(): ?int
{
return $this->id;
}
@@ -839,16 +844,16 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*
* If the person has a deathdate, calculate the age at the deathdate.
*
- * @param string $at a valid string to create a DateTime
- * @return int|null
+ * @param string $at A valid string to create a DateTime.
*/
- public function getAge($at = 'now'): ?int
+ public function getAge(string $at = 'now'): ?int
{
if ($this->birthdate instanceof \DateTimeInterface) {
if ($this->deathdate instanceof \DateTimeInterface) {
- return date_diff($this->birthdate, $this->deathdate)->format("%y");
+ return (int) date_diff($this->birthdate, $this->deathdate)->format('%y');
}
- return date_diff($this->birthdate, date_create($at))->format("%y");
+
+ return (int) date_diff($this->birthdate, date_create($at))->format('%y');
}
return null;
@@ -1089,9 +1094,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* Get nationality
*
- * @return Chill\MainBundle\Entity\Country
+ * @return Country
*/
- public function getNationality()
+ public function getNationality(): ?Country
{
return $this->nationality;
}
@@ -1171,7 +1176,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*
* @return string
*/
- public function getPhonenumber()
+ public function getPhonenumber(): string
{
return $this->phonenumber;
}
@@ -1194,7 +1199,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*
* @return string
*/
- public function getMobilenumber()
+ public function getMobilenumber(): string
{
return $this->mobilenumber;
}
diff --git a/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php b/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php
index 222495e17..c4497fce8 100644
--- a/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php
+++ b/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php
@@ -9,7 +9,10 @@ use Doctrine\ORM\Mapping as ORM;
* Person Phones
*
* @ORM\Entity
- * @ORM\Table(name="chill_person_phone")
+ * @ORM\Table(name="chill_person_phone",
+ * indexes={
+ * @ORM\Index(name="phonenumber", columns={"phonenumber"})
+ * })
*/
class PersonPhone
{
@@ -107,7 +110,7 @@ class PersonPhone
{
$this->date = $date;
}
-
+
public function isEmpty(): bool
{
return empty($this->getDescription()) && empty($this->getPhonenumber());
diff --git a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php
index 3fa8f5cda..704a6e47b 100644
--- a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php
+++ b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php
@@ -1,28 +1,10 @@
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
+declare(strict_types=1);
namespace Chill\PersonBundle\Form;
use Chill\MainBundle\Form\Event\CustomizeFormEvent;
-use Chill\MainBundle\Repository\CenterRepository;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
@@ -30,12 +12,9 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
-use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
-use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\PickCenterType;
use Chill\PersonBundle\Form\Type\GenderType;
-use Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer;
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
use Chill\PersonBundle\Form\Type\PersonAltNameType;
@@ -43,27 +22,19 @@ final class CreationPersonType extends AbstractType
{
// TODO: This is only used in test.
// TODO: See if this is still valid and update accordingly.
- const NAME = 'chill_personbundle_person_creation';
+ public const NAME = 'chill_personbundle_person_creation';
- private CenterRepository $centerRepository;
-
- /**
- *
- * @var ConfigPersonAltNamesHelper
- */
- protected $configPersonAltNamesHelper;
+ private ConfigPersonAltNamesHelper $configPersonAltNamesHelper;
private EventDispatcherInterface $dispatcher;
private bool $askCenters;
public function __construct(
- CenterRepository $centerRepository,
ConfigPersonAltNamesHelper $configPersonAltNamesHelper,
EventDispatcherInterface $dispatcher,
ParameterBagInterface $parameterBag
) {
- $this->centerTransformer = $centerRepository;
$this->configPersonAltNamesHelper = $configPersonAltNamesHelper;
$this->dispatcher = $dispatcher;
$this->askCenters = $parameterBag->get('chill_main')['acl']['form_show_centers'];
diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php
index 1f21defd9..430514d21 100644
--- a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php
+++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php
@@ -1,83 +1,49 @@
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
+
+declare(strict_types=1);
+
namespace Chill\PersonBundle\Form\SocialWork;
+use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
-use Chill\MainBundle\Templating\TranslatableStringHelper;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
-/**
- * Class SocialIssueType
- *
- * @package Chill\PersonBundle\Form
- */
class SocialIssueType extends AbstractType
{
- /**
- *
- * @var TranslatableStringHelper
- */
- protected $translatableStringHelper;
+ protected TranslatableStringHelperInterface $translatableStringHelper;
- public function __construct(TranslatableStringHelper $translatableStringHelper) {
+ public function __construct(
+ TranslatableStringHelperInterface $translatableStringHelper
+ ) {
$this->translatableStringHelper = $translatableStringHelper;
}
- /**
- * @param FormBuilderInterface $builder
- * @param array $options
- */
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', TranslatableStringFormType::class, [
'label' => 'Nom'
])
-
->add('parent', EntityType::class, [
'class' => SocialIssue::class,
'required' => false,
- 'choice_label' => function (SocialIssue $issue) {
- return $this->translatableStringHelper->localize($issue->getTitle());
- }
+ 'choice_label' => fn (SocialIssue $issue): ?string => $this->translatableStringHelper->localize($issue->getTitle())
])
-
->add('desactivationDate', DateType::class, [
'attr' => ['class' => 'datepicker'],
'widget'=> 'single_text',
'format' => 'dd-MM-yyyy',
'required' => false,
]);
-}
+ }
- /**
- * @param OptionsResolver $resolver
- */
public function configureOptions(OptionsResolver $resolver)
{
- $resolver
- ->setDefault('class', SocialIssue::class)
- ;
+ $resolver->setDefault('class', SocialIssue::class);
}
}
diff --git a/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php b/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php
index bdd31e899..5cad3b4f1 100644
--- a/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php
+++ b/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php
@@ -31,7 +31,7 @@ class GenderType extends AbstractType {
'choices' => $a,
'expanded' => true,
'multiple' => false,
- 'placeholder' => null
+ 'placeholder' => null,
));
}
diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php
index cd4f8c9ce..af8ed1a12 100644
--- a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php
+++ b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php
@@ -2,11 +2,15 @@
namespace Chill\PersonBundle\Repository;
+use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Repository\CountryRepository;
use Chill\MainBundle\Search\ParsingException;
+use Chill\MainBundle\Search\SearchApi;
+use Chill\MainBundle\Search\SearchApiQuery;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Entity\Person;
+use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\NoResultException;
@@ -49,125 +53,114 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac
string $default = null,
string $firstname = null,
string $lastname = null,
- ?\DateTime $birthdate = null,
- ?\DateTime $birthdateBefore = null,
- ?\DateTime $birthdateAfter = null,
+ ?\DateTimeInterface $birthdate = null,
+ ?\DateTimeInterface $birthdateBefore = null,
+ ?\DateTimeInterface $birthdateAfter = null,
string $gender = null,
- string $countryCode = null
+ string $countryCode = null,
+ string $phonenumber = null,
+ string $city = null
): array {
- $qb = $this->createSearchQuery($default, $firstname, $lastname,
+ $query = $this->buildAuthorizedQuery($default, $firstname, $lastname,
$birthdate, $birthdateBefore, $birthdateAfter, $gender,
- $countryCode);
- $this->addACLClauses($qb, 'p');
+ $countryCode, $phonenumber, $city);
- return $this->getQueryResult($qb, 'p', $simplify, $limit, $start);
- }
-
- /**
- * Helper method to prepare and return the search query for PersonACL.
- *
- * This method replace the select clause with required parameters, depending on the
- * "simplify" parameter. It also add query limits.
- *
- * The given alias must represent the person alias.
- *
- * @return array|Person[]
- */
- public function getQueryResult(QueryBuilder $qb, string $alias, bool $simplify, int $limit, int $start): array
- {
- if ($simplify) {
- $qb->select(
- $alias.'.id',
- $qb->expr()->concat(
- $alias.'.firstName',
- $qb->expr()->literal(' '),
- $alias.'.lastName'
- ).'AS text'
- );
- } else {
- $qb->select($alias);
- }
-
- $qb
- ->setMaxResults($limit)
- ->setFirstResult($start);
-
- //order by firstname, lastname
- $qb
- ->orderBy($alias.'.firstName')
- ->addOrderBy($alias.'.lastName');
-
- if ($simplify) {
- return $qb->getQuery()->getResult(Query::HYDRATE_ARRAY);
- } else {
- return $qb->getQuery()->getResult();
- }
+ return $this->fetchQueryPerson($query);
}
public function countBySearchCriteria(
string $default = null,
string $firstname = null,
string $lastname = null,
- ?\DateTime $birthdate = null,
- ?\DateTime $birthdateBefore = null,
- ?\DateTime $birthdateAfter = null,
+ ?\DateTimeInterface $birthdate = null,
+ ?\DateTimeInterface $birthdateBefore = null,
+ ?\DateTimeInterface $birthdateAfter = null,
string $gender = null,
- string $countryCode = null
+ string $countryCode = null,
+ string $phonenumber = null,
+ string $city = null
): int {
- $qb = $this->createSearchQuery($default, $firstname, $lastname,
+ $query = $this->buildAuthorizedQuery($default, $firstname, $lastname,
$birthdate, $birthdateBefore, $birthdateAfter, $gender,
- $countryCode);
- $this->addACLClauses($qb, 'p');
+ $countryCode, $phonenumber, $city)
+ ;
- return $this->getCountQueryResult($qb,'p');
+ return $this->fetchQueryCount($query);
+ }
+
+ public function fetchQueryCount(SearchApiQuery $query): int
+ {
+ $rsm = new Query\ResultSetMapping();
+ $rsm->addScalarResult('c', 'c');
+
+ $nql = $this->em->createNativeQuery($query->buildQuery(true), $rsm);
+ $nql->setParameters($query->buildParameters(true));
+
+ return $nql->getSingleScalarResult();
}
/**
- * Helper method to prepare and return the count for search query
- *
- * This method replace the select clause with required parameters, depending on the
- * "simplify" parameter.
- *
- * The given alias must represent the person alias in the query builder.
+ * @return array|Person[]
*/
- public function getCountQueryResult(QueryBuilder $qb, $alias): int
+ public function fetchQueryPerson(SearchApiQuery $query, ?int $start = 0, ?int $limit = 50): array
{
- $qb->select('COUNT('.$alias.'.id)');
+ $rsm = new Query\ResultSetMappingBuilder($this->em);
+ $rsm->addRootEntityFromClassMetadata(Person::class, 'person');
- return $qb->getQuery()->getSingleScalarResult();
+ $query->addSelectClause($rsm->generateSelectClause());
+
+ $nql = $this->em->createNativeQuery(
+ $query->buildQuery()." ORDER BY pertinence DESC OFFSET ? LIMIT ?", $rsm
+ )->setParameters(\array_merge($query->buildParameters(), [$start, $limit]));
+
+ return $nql->getResult();
}
- public function findBySimilaritySearch(string $pattern, int $firstResult,
- int $maxResult, bool $simplify = false)
- {
- $qb = $this->createSimilarityQuery($pattern);
- $this->addACLClauses($qb, 'sp');
+ public function buildAuthorizedQuery(
+ string $default = null,
+ string $firstname = null,
+ string $lastname = null,
+ ?\DateTimeInterface $birthdate = null,
+ ?\DateTimeInterface $birthdateBefore = null,
+ ?\DateTimeInterface $birthdateAfter = null,
+ string $gender = null,
+ string $countryCode = null,
+ string $phonenumber = null,
+ string $city = null
+ ): SearchApiQuery {
+ $query = $this->createSearchQuery($default, $firstname, $lastname,
+ $birthdate, $birthdateBefore, $birthdateAfter, $gender,
+ $countryCode, $phonenumber)
+ ;
- return $this->getQueryResult($qb, 'sp', $simplify, $maxResult, $firstResult);
+ return $this->addAuthorizations($query);
}
- public function countBySimilaritySearch(string $pattern)
+ private function addAuthorizations(SearchApiQuery $query): SearchApiQuery
{
- $qb = $this->createSimilarityQuery($pattern);
- $this->addACLClauses($qb, 'sp');
+ $authorizedCenters = $this->authorizationHelper
+ ->getReachableCenters($this->security->getUser(), PersonVoter::SEE);
- return $this->getCountQueryResult($qb, 'sp');
+ if ([] === $authorizedCenters) {
+ return $query->andWhereClause("FALSE = TRUE", []);
+ }
+
+ return $query
+ ->andWhereClause(
+ strtr(
+ "person.center_id IN ({{ center_ids }})",
+ [
+ '{{ center_ids }}' => \implode(', ',
+ \array_fill(0, count($authorizedCenters), '?')),
+ ]
+ ),
+ \array_map(function(Center $c) {return $c->getId();}, $authorizedCenters)
+ );
}
/**
* Create a search query without ACL
*
- * The person alias is a "p"
- *
- * @param string|null $default
- * @param string|null $firstname
- * @param string|null $lastname
- * @param \DateTime|null $birthdate
- * @param \DateTime|null $birthdateBefore
- * @param \DateTime|null $birthdateAfter
- * @param string|null $gender
- * @param string|null $countryCode
- * @return QueryBuilder
* @throws NonUniqueResultException
* @throws ParsingException
*/
@@ -175,118 +168,107 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac
string $default = null,
string $firstname = null,
string $lastname = null,
- ?\DateTime $birthdate = null,
- ?\DateTime $birthdateBefore = null,
- ?\DateTime $birthdateAfter = null,
+ ?\DateTimeInterface $birthdate = null,
+ ?\DateTimeInterface $birthdateBefore = null,
+ ?\DateTimeInterface $birthdateAfter = null,
string $gender = null,
- string $countryCode = null
- ): QueryBuilder {
+ string $countryCode = null,
+ string $phonenumber = null,
+ string $city = null
+ ): SearchApiQuery {
+ $query = new SearchApiQuery();
+ $query
+ ->setFromClause("chill_person_person AS person")
+ ;
- if (!$this->security->getUser() instanceof User) {
- throw new \RuntimeException("Search must be performed by a valid user");
- }
- $qb = $this->em->createQueryBuilder();
- $qb->from(Person::class, 'p');
+ $pertinence = [];
+ $pertinenceArgs = [];
+ $orWhereSearchClause = [];
+ $orWhereSearchClauseArgs = [];
- if (NULL !== $firstname) {
- $qb->andWhere($qb->expr()->like('UNACCENT(LOWER(p.firstName))', ':firstname'))
- ->setParameter('firstname', '%'.$firstname.'%');
- }
+ if ("" !== $default) {
+ foreach (\explode(" ", $default) as $str) {
+ $pertinence[] =
+ "STRICT_WORD_SIMILARITY(LOWER(UNACCENT(?)), person.fullnamecanonical) + ".
+ "(person.fullnamecanonical LIKE '%' || LOWER(UNACCENT(?)) || '%')::int + ".
+ "(EXISTS (SELECT 1 FROM unnest(string_to_array(fullnamecanonical, ' ')) AS t WHERE starts_with(t, UNACCENT(LOWER(?)))))::int";
+ \array_push($pertinenceArgs, $str, $str, $str);
- if (NULL !== $lastname) {
- $qb->andWhere($qb->expr()->like('UNACCENT(LOWER(p.lastName))', ':lastname'))
- ->setParameter('lastname', '%'.$lastname.'%');
+ $orWhereSearchClause[] =
+ "(LOWER(UNACCENT(?)) <<% person.fullnamecanonical OR ".
+ "person.fullnamecanonical LIKE '%' || LOWER(UNACCENT(?)) || '%' )";
+ \array_push($orWhereSearchClauseArgs, $str, $str);
+ }
+
+ $query->andWhereClause(\implode(' OR ', $orWhereSearchClause),
+ $orWhereSearchClauseArgs);
+ } else {
+ $pertinence = ["1"];
+ $pertinenceArgs = [];
}
+ $query
+ ->setSelectPertinence(\implode(' + ', $pertinence), $pertinenceArgs)
+ ;
if (NULL !== $birthdate) {
- $qb->andWhere($qb->expr()->eq('p.birthdate', ':birthdate'))
- ->setParameter('birthdate', $birthdate);
+ $query->andWhereClause(
+ "person.birthdate = ?::date",
+ [$birthdate->format('Y-m-d')]
+ );
}
-
- if (NULL !== $birthdateAfter) {
- $qb->andWhere($qb->expr()->gt('p.birthdate', ':birthdateafter'))
- ->setParameter('birthdateafter', $birthdateAfter);
+ if (NULL !== $firstname) {
+ $query->andWhereClause(
+ "UNACCENT(LOWER(person.firstname)) LIKE '%' || UNACCENT(LOWER(?)) || '%'",
+ [$firstname]
+ );
+ }
+ if (NULL !== $lastname) {
+ $query->andWhereClause(
+ "UNACCENT(LOWER(person.lastname)) LIKE '%' || UNACCENT(LOWER(?)) || '%'",
+ [$lastname]
+ );
}
-
if (NULL !== $birthdateBefore) {
- $qb->andWhere($qb->expr()->lt('p.birthdate', ':birthdatebefore'))
- ->setParameter('birthdatebefore', $birthdateBefore);
+ $query->andWhereClause(
+ 'p.birthdate < ?::date',
+ [$birthdateBefore->format('Y-m-d')]
+ );
}
-
- if (NULL !== $gender) {
- $qb->andWhere($qb->expr()->eq('p.gender', ':gender'))
- ->setParameter('gender', $gender);
+ if (NULL !== $birthdateAfter) {
+ $query->andWhereClause(
+ 'p.birthdate > ?::date',
+ [$birthdateAfter->format('Y-m-d')]
+ );
}
-
- if (NULL !== $countryCode) {
- try {
- $country = $this->countryRepository->findOneBy(['countryCode' => $countryCode]);
- } catch (NoResultException $ex) {
- throw new ParsingException('The country code "'.$countryCode.'" '
- . ', used in nationality, is unknow', 0, $ex);
- } catch (NonUniqueResultException $e) {
- throw $e;
- }
-
- $qb->andWhere($qb->expr()->eq('p.nationality', ':nationality'))
- ->setParameter('nationality', $country);
+ if (NULL !== $phonenumber) {
+ $query->andWhereClause(
+ "person.phonenumber LIKE '%' || ? || '%' OR person.mobilenumber LIKE '%' || ? || '%' OR pp.phonenumber LIKE '%' || ? || '%'"
+ ,
+ [$phonenumber, $phonenumber, $phonenumber]
+ );
+ $query->setFromClause($query->getFromClause()." LEFT JOIN chill_person_phone pp ON pp.person_id = person.id");
}
+ if (null !== $city) {
+ $query->setFromClause($query->getFromClause()." ".
+ "JOIN view_chill_person_current_address vcpca ON vcpca.person_id = person.id ".
+ "JOIN chill_main_address cma ON vcpca.address_id = cma.id ".
+ "JOIN chill_main_postal_code cmpc ON cma.postcode_id = cmpc.id");
- if (NULL !== $default) {
- $grams = explode(' ', $default);
-
- foreach($grams as $key => $gram) {
- $qb->andWhere($qb->expr()
- ->like('p.fullnameCanonical', 'UNACCENT(LOWER(:default_'.$key.'))'))
- ->setParameter('default_'.$key, '%'.$gram.'%');
+ foreach (\explode(" ", $city) as $cityStr) {
+ $query->andWhereClause(
+ "(UNACCENT(LOWER(cmpc.label)) LIKE '%' || UNACCENT(LOWER(?)) || '%' OR cmpc.code LIKE '%' || UNACCENT(LOWER(?)) || '%')",
+ [$cityStr, $city]
+ );
}
}
-
- return $qb;
- }
-
- private function addACLClauses(QueryBuilder $qb, string $personAlias): void
- {
- // restrict center for security
- $reachableCenters = $this->authorizationHelper
- ->getReachableCenters($this->security->getUser(), 'CHILL_PERSON_SEE');
- $qb->andWhere(
- $qb->expr()->orX(
- $qb->expr()
- ->in($personAlias.'.center', ':centers'),
- $qb->expr()
- ->isNull($personAlias.'.center')
- )
- );
- $qb->setParameter('centers', $reachableCenters);
- }
-
- /**
- * Create a query for searching by similarity.
- *
- * The person alias is "sp".
- *
- * @param $pattern
- * @return QueryBuilder
- */
- public function createSimilarityQuery($pattern): QueryBuilder
- {
- $qb = $this->em->createQueryBuilder();
-
- $qb->from(Person::class, 'sp');
-
- $grams = explode(' ', $pattern);
-
- foreach($grams as $key => $gram) {
- $qb->andWhere('STRICT_WORD_SIMILARITY_OPS(:default_'.$key.', sp.fullnameCanonical) = TRUE')
- ->setParameter('default_'.$key, '%'.$gram.'%');
-
- // remove the perfect matches
- $qb->andWhere($qb->expr()
- ->notLike('sp.fullnameCanonical', 'UNACCENT(LOWER(:not_default_'.$key.'))'))
- ->setParameter('not_default_'.$key, '%'.$gram.'%');
+ if (null !== $countryCode) {
+ $query->setFromClause($query->getFromClause()." JOIN country ON person.nationality_id = country.id");
+ $query->andWhereClause("country.countrycode = UPPER(?)", [$countryCode]);
+ }
+ if (null !== $gender) {
+ $query->andWhereClause("person.gender = ?", [$gender]);
}
- return $qb;
+ return $query;
}
}
diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepositoryInterface.php b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepositoryInterface.php
index 8e83da03d..89566b5a6 100644
--- a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepositoryInterface.php
+++ b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepositoryInterface.php
@@ -3,16 +3,14 @@
namespace Chill\PersonBundle\Repository;
use Chill\MainBundle\Search\ParsingException;
+use Chill\MainBundle\Search\SearchApiQuery;
use Chill\PersonBundle\Entity\Person;
use Doctrine\ORM\NonUniqueResultException;
interface PersonACLAwareRepositoryInterface
{
-
/**
* @return array|Person[]
- * @throws NonUniqueResultException
- * @throws ParsingException
*/
public function findBySearchCriteria(
int $start,
@@ -21,30 +19,38 @@ interface PersonACLAwareRepositoryInterface
string $default = null,
string $firstname = null,
string $lastname = null,
- ?\DateTime $birthdate = null,
- ?\DateTime $birthdateBefore = null,
- ?\DateTime $birthdateAfter = null,
+ ?\DateTimeInterface $birthdate = null,
+ ?\DateTimeInterface $birthdateBefore = null,
+ ?\DateTimeInterface $birthdateAfter = null,
string $gender = null,
- string $countryCode = null
+ string $countryCode = null,
+ string $phonenumber = null,
+ string $city = null
): array;
public function countBySearchCriteria(
string $default = null,
string $firstname = null,
string $lastname = null,
- ?\DateTime $birthdate = null,
- ?\DateTime $birthdateBefore = null,
- ?\DateTime $birthdateAfter = null,
+ ?\DateTimeInterface $birthdate = null,
+ ?\DateTimeInterface $birthdateBefore = null,
+ ?\DateTimeInterface $birthdateAfter = null,
string $gender = null,
- string $countryCode = null
+ string $countryCode = null,
+ string $phonenumber = null,
+ string $city = null
);
- public function findBySimilaritySearch(
- string $pattern,
- int $firstResult,
- int $maxResult,
- bool $simplify = false
- );
-
- public function countBySimilaritySearch(string $pattern);
+ public function buildAuthorizedQuery(
+ string $default = null,
+ string $firstname = null,
+ string $lastname = null,
+ ?\DateTimeInterface $birthdate = null,
+ ?\DateTimeInterface $birthdateBefore = null,
+ ?\DateTimeInterface $birthdateAfter = null,
+ string $gender = null,
+ string $countryCode = null,
+ string $phonenumber = null,
+ string $city = null
+ ): SearchApiQuery;
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/badge.scss b/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/badge.scss
index 7e9f13149..7dc626858 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/badge.scss
+++ b/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/badge.scss
@@ -60,6 +60,16 @@ h2.badge-title {
h3 {
margin-bottom: 0.5rem;
}
+
+ //position: relative;
+ span {
+ display: none;
+ //position: absolute;
+ //top: 0;
+ //left: 0;
+ //transform: rotate(270deg);
+ //transform-origin: 0 0;
+ }
}
span.title_action {
flex-grow: 1;
@@ -117,3 +127,36 @@ div.activity-list {
}
}
}
+
+/// AccompanyingCourse: HeaderSlider Carousel
+div#header-accompanying_course-details {
+ button.carousel-control-prev,
+ button.carousel-control-next {
+ width: 8%;
+ opacity: inherit;
+ }
+ button.carousel-control-prev {
+ left: unset;
+ right: 0;
+ }
+ span.to-social-issues,
+ span.to-persons-associated {
+ display: inline-block;
+ border-radius: 15px;
+ width: 24px;
+ height: 24px;
+ box-shadow: 0 0 3px 1px grey;
+ opacity: 0.8;
+ &:hover {
+ opacity: 1;
+ }
+ }
+ span.to-social-issues {
+ background-color: #4bafe8;
+ border-left: 12px solid #32749a;
+ }
+ span.to-persons-associated {
+ background-color: #16d9b4;
+ border-right: 12px solid #ffffff;
+ }
+}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/mixins.scss b/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/mixins.scss
index e995f97eb..878ff82e1 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/mixins.scss
+++ b/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/mixins.scss
@@ -4,7 +4,7 @@
///
@mixin chill_badge($color) {
- text-transform: capitalize !important;
+ //text-transform: capitalize !important;
font-weight: 500 !important;
border-left: 20px groove $color;
&:before {
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue
index 84e7fb2c6..7cce4d900 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue
@@ -22,20 +22,22 @@
{{ $t('course.open_at') }}{{ $d(accompanyingCourse.openingDate.datetime, 'text') }}
- {{ $t('course.referrer') }}: {{ accompanyingCourse.user.username }}
+ {{ $t('course.referrer') }}: {{ accompanyingCourse.user.username }}
-
-
-
-
+
+
+
+
+
+
@@ -43,12 +45,14 @@
+
+
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue
index f23a7c9e5..4142b4f50 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue
@@ -10,7 +10,7 @@
{{ $t('confirm.alert_validation') }}
- -
+
-
{{ $t(notValidMessages[k].msg) }}
@@ -83,7 +83,11 @@ export default {
},
location: {
msg: 'confirm.location_not_valid',
- anchor: '#section-20' //
+ anchor: '#section-20'
+ },
+ origin: {
+ msg: 'confirm.origin_not_valid',
+ anchor: '#section-30'
},
socialIssue: {
msg: 'confirm.socialIssue_not_valid',
@@ -103,6 +107,7 @@ export default {
...mapGetters([
'isParticipationValid',
'isSocialIssueValid',
+ 'isOriginValid',
'isLocationValid',
'validationKeys',
'isValidToBeConfirmed'
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue
index 30ad6afe0..b88bf0747 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue
@@ -19,15 +19,18 @@
:options="options"
@select="updateOrigin">
-
+
+
+ {{ $t('origin.not_valid') }}
+