Browse Source

Merge branch 'develop'

develop
Guillaume Bourgeois 2 years ago
parent
commit
7f18740ce6
3 changed files with 44 additions and 2 deletions
  1. +20
    -0
      Component/ArrayComponent.php
  2. +9
    -1
      Container/ComponentContainer.php
  3. +15
    -1
      Repository/AbstractRepositoryQuery.php

+ 20
- 0
Component/ArrayComponent.php View File

<?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 View File

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

+ 15
- 1
Repository/AbstractRepositoryQuery.php View File

return $this; return $this;
}*/ }*/


// @TODO : créer un addOrderBy et un orderBy
public function orderBy(string $field, string $sort = 'ASC'): self public function orderBy(string $field, string $sort = 'ASC'): self
{ {
if (strpos($field, '.')!==false) { if (strpos($field, '.')!==false) {
} }
} }


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

public function filterById(int $id):self public function filterById(int $id):self
{ {
return $this return $this
{ {
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);
}

} }



Loading…
Cancel
Save