Browse Source

News

packProduct
Charly 3 years ago
parent
commit
de2b2340de
2 changed files with 59 additions and 3 deletions
  1. +34
    -3
      Repository/Reminder/ReminderStore.php
  2. +25
    -0
      Repository/Site/NewsStore.php

+ 34
- 3
Repository/Reminder/ReminderStore.php View File

@@ -6,6 +6,7 @@ use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\Reminder\ReminderStore as SovReminderStore;

class ReminderStore extends SovReminderStore
@@ -15,19 +16,49 @@ class ReminderStore extends SovReminderStore

public function get($params = [], $query = null)
{
if(is_null($query)) {
if (is_null($query)) {
$query = $this->query->create();
}

if($this->merchant) {
if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

if($this->section) {
if ($this->section) {
$query->filterBySection($this->section);
}

return parent::get($params, $query);
}

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

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

return parent::getByUser($user, $query);
}

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

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

return parent::getByEasyAdminConfigAndUser($crudAction, $crudControllerFqcn, $user, $entityId, $query);
}
}

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

@@ -0,0 +1,25 @@
<?php

namespace Lc\CaracoleBundle\Repository\Site;

use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\SovBundle\Repository\Site\NewsStore as SovNewsStore;

class NewsStore extends SovNewsStore
{
use MerchantStoreTrait;

public function getLatests(int $maxResults = 0, $query = null): array
{
if (is_null($query)) {
$query = $this->query->create();
}

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

return parent::getLatests($maxResults, $query);
}

}

Loading…
Cancel
Save