Browse Source

New

feature/symfony6.1
Charly 3 years ago
parent
commit
0b4012f138
3 changed files with 50 additions and 5 deletions
  1. +12
    -5
      Repository/Reminder/ReminderStore.php
  2. +6
    -0
      Repository/Site/NewsRepositoryQuery.php
  3. +32
    -0
      Repository/Site/NewsStore.php

+ 12
- 5
Repository/Reminder/ReminderStore.php View File

@@ -46,8 +46,12 @@ class ReminderStore extends AbstractStore implements ReminderStoreInterface
}

// findByUser
public function getByUser(UserInterface $user): array
public function getByUser(UserInterface $user, $query = null): array
{
if (is_null($query)) {
$query = $this->query->create();
}

$query = $this->query->create();

$query
@@ -61,12 +65,15 @@ class ReminderStore extends AbstractStore implements ReminderStoreInterface

// findByEasyAdminConfigAndUser
public function getByEasyAdminConfigAndUser(
$crudAction,
$crudControllerFqcn,
string $crudAction,
string $crudControllerFqcn,
UserInterface $user,
$entityId = null
int $entityId = null,
$query = null
): array {
$query = $this->query->create();
if (is_null($query)) {
$query = $this->query->create();
}

$query
->filterByUser($user)

+ 6
- 0
Repository/Site/NewsRepositoryQuery.php View File

@@ -3,10 +3,16 @@
namespace Lc\SovBundle\Repository\Site;

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\StatusRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class NewsRepositoryQuery extends AbstractRepositoryQuery implements NewsRepositoryQueryInterface
{
use StatusRepositoryQueryTrait;
use MerchantRepositoryQueryTrait;

public function __construct(NewsRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'r', $paginator);

+ 32
- 0
Repository/Site/NewsStore.php View File

@@ -12,4 +12,36 @@ class NewsStore extends AbstractStore implements NewsStoreInterface
{
$this->query = $query;
}

//findLatests
public function getLatests(int $maxResults = 0, $query = null): array
{
if (is_null($query)) {
$query = $this->query->create();
}
$query
->filterIsOnline()
->orderBy('.date', 'DESC');

if ($maxResults) {
$query
->limit($maxResults);
}

return $query->find();
}

public function findLatests($maxResults = 0)
{
$result = $this->findByMerchantQuery()
->orderBy('e.date', 'DESC');

$result->andWhere('e.status = 1');

if ($maxResults) {
$result->setMaxResults($maxResults);
}

return $result->getQuery()->getResult();
}
}

Loading…
Cancel
Save