@@ -0,0 +1,20 @@ | |||
<?php | |||
namespace Lc\SovBundle\Component; | |||
use Cocur\Slugify\Slugify; | |||
class ArrayComponent | |||
{ | |||
public function contains(array $array, $entity): bool | |||
{ | |||
foreach($array as $entityTest) { | |||
if(get_class($entityTest) == get_class($entity) | |||
&& $entityTest->getId() == $entity->getId()) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
} | |||
} |
@@ -26,6 +26,7 @@ class ComponentContainer | |||
protected NumberComponent $numberComponent; | |||
protected PointLocationComponent $pointLocationComponent; | |||
protected StringComponent $stringComponent; | |||
protected ArrayComponent $arrayComponent; | |||
public function __construct( | |||
CitiesComponent $citiesComponent, | |||
@@ -37,7 +38,8 @@ class ComponentContainer | |||
MetaComponent $metaComponent, | |||
NumberComponent $numberComponent, | |||
PointLocationComponent $pointLocationComponent, | |||
StringComponent $stringComponent | |||
StringComponent $stringComponent, | |||
ArrayComponent $arrayComponent | |||
) { | |||
$this->citiesComponent = $citiesComponent; | |||
$this->cookieComponent = $cookieComponent; | |||
@@ -49,6 +51,7 @@ class ComponentContainer | |||
$this->numberComponent = $numberComponent; | |||
$this->pointLocationComponent = $pointLocationComponent; | |||
$this->stringComponent = $stringComponent; | |||
$this->arrayComponent = $arrayComponent; | |||
} | |||
public function getCitiesComponent(): CitiesComponent | |||
@@ -100,4 +103,9 @@ class ComponentContainer | |||
{ | |||
return $this->stringComponent; | |||
} | |||
public function getArrayComponent(): ArrayComponent | |||
{ | |||
return $this->arrayComponent; | |||
} | |||
} |
@@ -146,7 +146,7 @@ abstract class AbstractFieldDefinition | |||
$fieldArray = []; | |||
foreach($configureFieldArray as $fieldName) { | |||
if(isset($allFieldArray[$fieldName])) { | |||
$fieldArray[] = $allFieldArray[$fieldName]; | |||
$fieldArray[$fieldName] = $allFieldArray[$fieldName]; | |||
} | |||
else { | |||
throw new \ErrorException('Le field "'.$fieldName.'" n\'est pas défini dans configureFields()'); |
@@ -251,5 +251,14 @@ abstract class AbstractRepositoryQuery implements RepositoryQueryInterface | |||
{ | |||
return $this->andWhere('.position < :position')->setParameter('position', $position); | |||
} | |||
public function enableCache($lifetime, $idCache) | |||
{ | |||
return $this->getQueryBuilder()->getQuery() | |||
->useQueryCache(true) | |||
->setQueryCacheLifetime($lifetime) | |||
->enableResultCache($lifetime, $idCache); | |||
} | |||
} | |||
@@ -100,16 +100,18 @@ export class SovWidgets { | |||
static setAutoCompleteField() { | |||
var autocompleteFields = $('[data-lc-autocomplete-url]'); | |||
autocompleteFields.each(function () { | |||
var $this = $(this), | |||
url = $this.data('lc-autocomplete-url'); | |||
$this.autoComplete({ | |||
//bootstrapVersion: 4, | |||
//noResultsText: 'Aucun résultat n\'a été trouvé.', | |||
resolverSettings: { | |||
url: url | |||
} | |||
}); | |||
if(!$(this).hasClass('autocomplete-disabled')) { | |||
var $this = $(this), | |||
url = $this.data('lc-autocomplete-url'); | |||
$this.autoComplete({ | |||
//bootstrapVersion: 4, | |||
//noResultsText: 'Aucun résultat n\'a été trouvé.', | |||
resolverSettings: { | |||
url: url | |||
} | |||
}); | |||
} | |||
}); | |||
} | |||