<?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; | |||||
} | |||||
} |
protected NumberComponent $numberComponent; | protected NumberComponent $numberComponent; | ||||
protected PointLocationComponent $pointLocationComponent; | protected PointLocationComponent $pointLocationComponent; | ||||
protected StringComponent $stringComponent; | protected StringComponent $stringComponent; | ||||
protected ArrayComponent $arrayComponent; | |||||
public function __construct( | public function __construct( | ||||
CitiesComponent $citiesComponent, | CitiesComponent $citiesComponent, | ||||
MetaComponent $metaComponent, | MetaComponent $metaComponent, | ||||
NumberComponent $numberComponent, | NumberComponent $numberComponent, | ||||
PointLocationComponent $pointLocationComponent, | PointLocationComponent $pointLocationComponent, | ||||
StringComponent $stringComponent | |||||
StringComponent $stringComponent, | |||||
ArrayComponent $arrayComponent | |||||
) { | ) { | ||||
$this->citiesComponent = $citiesComponent; | $this->citiesComponent = $citiesComponent; | ||||
$this->cookieComponent = $cookieComponent; | $this->cookieComponent = $cookieComponent; | ||||
$this->numberComponent = $numberComponent; | $this->numberComponent = $numberComponent; | ||||
$this->pointLocationComponent = $pointLocationComponent; | $this->pointLocationComponent = $pointLocationComponent; | ||||
$this->stringComponent = $stringComponent; | $this->stringComponent = $stringComponent; | ||||
$this->arrayComponent = $arrayComponent; | |||||
} | } | ||||
public function getCitiesComponent(): CitiesComponent | public function getCitiesComponent(): CitiesComponent | ||||
{ | { | ||||
return $this->stringComponent; | return $this->stringComponent; | ||||
} | } | ||||
public function getArrayComponent(): ArrayComponent | |||||
{ | |||||
return $this->arrayComponent; | |||||
} | |||||
} | } |
$fieldArray = []; | $fieldArray = []; | ||||
foreach($configureFieldArray as $fieldName) { | foreach($configureFieldArray as $fieldName) { | ||||
if(isset($allFieldArray[$fieldName])) { | if(isset($allFieldArray[$fieldName])) { | ||||
$fieldArray[] = $allFieldArray[$fieldName]; | |||||
$fieldArray[$fieldName] = $allFieldArray[$fieldName]; | |||||
} | } | ||||
else { | else { | ||||
throw new \ErrorException('Le field "'.$fieldName.'" n\'est pas défini dans configureFields()'); | throw new \ErrorException('Le field "'.$fieldName.'" n\'est pas défini dans configureFields()'); |
{ | { | ||||
return $this->andWhere('.position < :position')->setParameter('position', $position); | return $this->andWhere('.position < :position')->setParameter('position', $position); | ||||
} | } | ||||
public function enableCache($lifetime, $idCache) | |||||
{ | |||||
return $this->getQueryBuilder()->getQuery() | |||||
->useQueryCache(true) | |||||
->setQueryCacheLifetime($lifetime) | |||||
->enableResultCache($lifetime, $idCache); | |||||
} | |||||
} | } | ||||
static setAutoCompleteField() { | static setAutoCompleteField() { | ||||
var autocompleteFields = $('[data-lc-autocomplete-url]'); | var autocompleteFields = $('[data-lc-autocomplete-url]'); | ||||
autocompleteFields.each(function () { | 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 | |||||
} | |||||
}); | |||||
} | |||||
}); | }); | ||||
} | } | ||||