Przeglądaj źródła

Merge branch 'develop'

develop
Guillaume Bourgeois 2 lat temu
rodzic
commit
7f18740ce6
3 zmienionych plików z 44 dodań i 2 usunięć
  1. +20
    -0
      Component/ArrayComponent.php
  2. +9
    -1
      Container/ComponentContainer.php
  3. +15
    -1
      Repository/AbstractRepositoryQuery.php

+ 20
- 0
Component/ArrayComponent.php Wyświetl plik

@@ -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;
}
}

+ 9
- 1
Container/ComponentContainer.php Wyświetl plik

@@ -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;
}
}

+ 15
- 1
Repository/AbstractRepositoryQuery.php Wyświetl plik

@@ -131,7 +131,6 @@ abstract class AbstractRepositoryQuery implements RepositoryQueryInterface
return $this;
}*/

// @TODO : créer un addOrderBy et un orderBy
public function orderBy(string $field, string $sort = 'ASC'): self
{
if (strpos($field, '.')!==false) {
@@ -141,6 +140,12 @@ abstract class AbstractRepositoryQuery implements RepositoryQueryInterface
}
}

public function setOrderBy(string $field, string $sort = 'ASC'): self
{
$this->resetDQLParts(['orderBy']);
return $this->orderBy($field, $sort);
}

public function filterById(int $id):self
{
return $this
@@ -251,5 +256,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);
}

}


Ładowanie…
Anuluj
Zapisz