namespace Lc\CaracoleBundle\Repository\Reminder; | namespace Lc\CaracoleBundle\Repository\Reminder; | ||||
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | ||||
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | |||||
use Lc\SovBundle\Repository\Reminder\ReminderRepositoryQuery as SovReminderRepositoryQuery; | use Lc\SovBundle\Repository\Reminder\ReminderRepositoryQuery as SovReminderRepositoryQuery; | ||||
class ReminderRepositoryQuery extends SovReminderRepositoryQuery | class ReminderRepositoryQuery extends SovReminderRepositoryQuery | ||||
{ | { | ||||
use MerchantRepositoryQueryTrait; | use MerchantRepositoryQueryTrait; | ||||
use SectionRepositoryQueryTrait; | |||||
} | } |
<?php | |||||
namespace Lc\CaracoleBundle\Repository\Reminder; | |||||
use Lc\SovBundle\Repository\Reminder\ReminderStore as SovReminderStore; | |||||
class ReminderStore extends SovReminderStore | |||||
{ | |||||
public function get($params = []) | |||||
{ | |||||
$query = $this->query->create(); | |||||
$query->filterBase($params) ; | |||||
if(array_key_exists('merchant', $params)) { | |||||
$query->filterByMerchant($params['merchant']); | |||||
} | |||||
if(array_key_exists('section', $params)) { | |||||
$query->filterBySection($params['section']); | |||||
} | |||||
return $query->find(); | |||||
} | |||||
} |
</nav> | </nav> | ||||
{% endblock %} | {% endblock %} | ||||
{% block reminders %} | |||||
{% set reminders = carac_reminders(params_reminders) %} | |||||
{% include '@LcSov/admin/reminder/block.html.twig' %} | |||||
{% endblock %} | |||||
{% block append_body %} | {% block append_body %} | ||||
{# modal switch merchant #} | {# modal switch merchant #} | ||||
{% set user = app.user %} | {% set user = app.user %} | ||||
comme marchand favoris ou simplement indiquer que vous visitez ce marchand pour aujourd'hui.</p> | comme marchand favoris ou simplement indiquer que vous visitez ce marchand pour aujourd'hui.</p> | ||||
{% endblock %} | {% endblock %} | ||||
{% block footer %} | {% block footer %} | ||||
{% set form_switch_merchant = carac_form_switch_merchant('admin', 'carac_favorite_merchant') %} | |||||
{% set form_switch_merchant = carac_form_switch_merchant('admin', 'carac_merchant_favorite') %} | |||||
{% form_theme form_switch_merchant '@LcSov/adminlte/crud/form_theme.html.twig' %} | {% form_theme form_switch_merchant '@LcSov/adminlte/crud/form_theme.html.twig' %} | ||||
{{ form_start(form_switch_merchant) }} | {{ form_start(form_switch_merchant) }} | ||||
{{ form(form_switch_merchant) }} | {{ form(form_switch_merchant) }} |
namespace Lc\CaracoleBundle\Twig; | namespace Lc\CaracoleBundle\Twig; | ||||
use Lc\CaracoleBundle\Repository\Merchant\MerchantRepositoryQuery; | use Lc\CaracoleBundle\Repository\Merchant\MerchantRepositoryQuery; | ||||
use Lc\CaracoleBundle\Repository\Reminder\ReminderStore; | |||||
use Lc\CaracoleBundle\Repository\Section\SectionRepository; | use Lc\CaracoleBundle\Repository\Section\SectionRepository; | ||||
use Lc\CaracoleBundle\Repository\Section\SectionRepositoryInterface; | use Lc\CaracoleBundle\Repository\Section\SectionRepositoryInterface; | ||||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||||
use Twig\Extension\AbstractExtension; | use Twig\Extension\AbstractExtension; | ||||
use Twig\TwigFunction; | use Twig\TwigFunction; | ||||
{ | { | ||||
protected $merchantRepository; | protected $merchantRepository; | ||||
protected $sectionRepository; | protected $sectionRepository; | ||||
protected ReminderStore $reminderStore; | |||||
protected MerchantResolver $merchantResolver; | |||||
protected SectionResolver $sectionResolver; | |||||
public function __construct( | public function __construct( | ||||
MerchantResolver $merchantResolver, | |||||
SectionResolver $sectionResolver, | |||||
MerchantRepositoryQuery $merchantRepository, | MerchantRepositoryQuery $merchantRepository, | ||||
SectionRepository $sectionRepository | |||||
SectionRepository $sectionRepository, | |||||
ReminderStore $reminderStore | |||||
) { | ) { | ||||
$this->merchantResolver = $merchantResolver; | |||||
$this->sectionResolver = $sectionResolver; | |||||
$this->merchantRepository = $merchantRepository; | $this->merchantRepository = $merchantRepository; | ||||
$this->sectionRepository = $sectionRepository; | $this->sectionRepository = $sectionRepository; | ||||
$this->reminderStore = $reminderStore; | |||||
} | } | ||||
public function getFunctions() | public function getFunctions() | ||||
return array( | return array( | ||||
new TwigFunction('carac_sections', [$this, 'getSections']), | new TwigFunction('carac_sections', [$this, 'getSections']), | ||||
new TwigFunction('carac_merchants', [$this, 'getMerchants']), | new TwigFunction('carac_merchants', [$this, 'getMerchants']), | ||||
new TwigFunction('carac_reminders', [$this, 'getReminders']), | |||||
); | ); | ||||
} | } | ||||
return $this->merchantRepository->findAll(); | return $this->merchantRepository->findAll(); | ||||
} | } | ||||
public function getReminders($params = []) | |||||
{ | |||||
$params['merchant'] = $this->merchantResolver->getCurrent(); | |||||
$params['section'] = $this->sectionResolver->getCurrent(); | |||||
return $this->reminderStore->get($params); | |||||
} | |||||
} | } |