use Lc\CaracoleBundle\Resolver\MerchantResolver; | use Lc\CaracoleBundle\Resolver\MerchantResolver; | ||||
use Lc\CaracoleBundle\Resolver\SectionResolver; | use Lc\CaracoleBundle\Resolver\SectionResolver; | ||||
use Lc\CaracoleBundle\Definition\SectionSettingDefinitionInterface; | use Lc\CaracoleBundle\Definition\SectionSettingDefinitionInterface; | ||||
use Lc\SovBundle\Definition\SiteSettingDefinition; | |||||
use Lc\SovBundle\Form\Setting\SiteSettingsFormType; | |||||
use Lc\SovBundle\Repository\Site\SiteRepository; | |||||
use Lc\SovBundle\Translation\TranslatorAdmin; | use Lc\SovBundle\Translation\TranslatorAdmin; | ||||
use Symfony\Component\HttpFoundation\Request; | use Symfony\Component\HttpFoundation\Request; | ||||
class SettingAdminController extends SovSettingController | class SettingAdminController extends SovSettingController | ||||
{ | { | ||||
protected $em; | protected $em; | ||||
protected $translatorAdmin; | |||||
protected $merchantResolver; | protected $merchantResolver; | ||||
protected $merchantSettingDefinition; | protected $merchantSettingDefinition; | ||||
protected $sectionResolver; | protected $sectionResolver; | ||||
protected $sectionSettingDefinition; | protected $sectionSettingDefinition; | ||||
protected $translatorAdmin; | |||||
protected $siteSettingDefinition; | |||||
protected $siteRepository; | |||||
public function __construct( | public function __construct( | ||||
EntityManagerInterface $em, | |||||
MerchantResolver $merchantResolver, | |||||
SectionResolver $sectionResolver, | |||||
MerchantSettingDefinitionInterface $merchantSettingDefinition, | |||||
SectionSettingDefinitionInterface $sectionSettingDefinition, | |||||
TranslatorAdmin $translatorAdmin | |||||
) | |||||
{ | |||||
EntityManagerInterface $em, | |||||
TranslatorAdmin $translatorAdmin, | |||||
MerchantResolver $merchantResolver, | |||||
SectionResolver $sectionResolver, | |||||
MerchantSettingDefinitionInterface $merchantSettingDefinition, | |||||
SectionSettingDefinitionInterface $sectionSettingDefinition, | |||||
SiteSettingDefinition $siteSettingDefinition, | |||||
SiteRepository $siteRepository | |||||
) { | |||||
$this->em = $em; | $this->em = $em; | ||||
$this->translatorAdmin = $translatorAdmin; | |||||
$this->merchantResolver = $merchantResolver; | $this->merchantResolver = $merchantResolver; | ||||
$this->sectionResolver = $sectionResolver; | $this->sectionResolver = $sectionResolver; | ||||
$this->merchantSettingDefinition = $merchantSettingDefinition; | $this->merchantSettingDefinition = $merchantSettingDefinition; | ||||
$this->sectionSettingDefinition = $sectionSettingDefinition; | $this->sectionSettingDefinition = $sectionSettingDefinition; | ||||
$this->translatorAdmin = $translatorAdmin; | |||||
$this->siteSettingDefinition = $siteSettingDefinition; | |||||
$this->siteRepository = $siteRepository; | |||||
} | } | ||||
public function manageMerchant(Request $request) | public function manageMerchant(Request $request) | ||||
$entity = $resolver->getCurrent(); | $entity = $resolver->getCurrent(); | ||||
if ($entity) { | if ($entity) { | ||||
$form = $this->createForm($formClass, $entity); | $form = $this->createForm($formClass, $entity); | ||||
$form->handleRequest($request); | $form->handleRequest($request); | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
public function manageGlobal(Request $request) | |||||
{ | |||||
$site = $this->siteRepository->findOneByDevAlias('default') ; | |||||
$form = $this->createForm(SiteSettingsFormType::class, $site); | |||||
$form->handleRequest($request); | |||||
if ($form->isSubmitted() && $form->isValid()) { | |||||
$this->em->update($site); | |||||
$this->em->flush(); | |||||
$this->addFlash('success', $this->translatorAdmin->transFlashMessage('settings_saved')); | |||||
} | |||||
return $this->render( | |||||
'@LcCaracole/admin/setting/global.html.twig' , | |||||
[ | |||||
'setting_definition' => $this->siteSettingDefinition, | |||||
'form' => $form->createView() | |||||
] | |||||
); | |||||
} | |||||
} | } |
namespace Lc\CaracoleBundle\Definition; | namespace Lc\CaracoleBundle\Definition; | ||||
use Lc\SovBundle\Definition\AbstractSettingDefinition; | |||||
class MerchantSettingDefinition extends AbstractSettingDefinition implements MerchantSettingDefinitionInterface | class MerchantSettingDefinition extends AbstractSettingDefinition implements MerchantSettingDefinitionInterface | ||||
{ | { |
$this->sectionRepository->findAll(), | $this->sectionRepository->findAll(), | ||||
$this->sectionSettingFactory | $this->sectionSettingFactory | ||||
); | ); | ||||
} | } | ||||
public function initSettingsGeneric($type, $settings, $entities, $factory) | public function initSettingsGeneric($type, $settings, $entities, $factory) |
public function setUserRolesFromKernelRequest(RequestEvent $event) | public function setUserRolesFromKernelRequest(RequestEvent $event) | ||||
{ | { | ||||
if (!$event->isMainRequest()) { | |||||
if (!$event->isMasterRequest()) { | |||||
return; | return; | ||||
} | } | ||||
if ($this->setUserRoles($event->getRequest())) { | if ($this->setUserRoles($event->getRequest())) { |
use Symfony\Component\Form\FormEvent; | use Symfony\Component\Form\FormEvent; | ||||
use Symfony\Component\Form\FormEvents; | use Symfony\Component\Form\FormEvents; | ||||
use Symfony\Component\OptionsResolver\OptionsResolver; | use Symfony\Component\OptionsResolver\OptionsResolver; | ||||
use Lc\SovBundle\Form\Setting\BaseSettingType as SovBaseSettingType; | |||||
abstract class BaseSettingType extends AbstractType | |||||
abstract class BaseSettingType extends SovBaseSettingType | |||||
{ | { | ||||
protected $em; | protected $em; | ||||
protected $merchantSettingDefinition; | protected $merchantSettingDefinition; | ||||
$transCategory = 'section' ; | $transCategory = 'section' ; | ||||
$settingDefinition = $sectionSettingDefinition ; | $settingDefinition = $sectionSettingDefinition ; | ||||
} | } | ||||
$label = 'setting_definition.'.$transCategory.'.settings.'.$settingName ; | |||||
if($settingDefinition) { | |||||
$setting = $settingDefinition->getSettingByName($settingName); | |||||
$settingType = $settingDefinition->getSettingType($settingName); | |||||
$label = 'setting_definition.'.$transCategory.'.settings.'.$settingName ; | |||||
if ($settingType == 'text') { | |||||
$form->add( | |||||
'text', | |||||
TextType::class, | |||||
[ | |||||
'label' => $label | |||||
] | |||||
); | |||||
} | |||||
elseif ($settingType == 'textarea') { | |||||
$form->add( | |||||
'text', | |||||
TextareaType::class, | |||||
[ | |||||
'label' => $label | |||||
] | |||||
); | |||||
} | |||||
elseif ($settingType == 'textarea_advanced') { | |||||
$form->add( | |||||
'text', | |||||
CKEditorType::class, | |||||
[ | |||||
'label' => $label | |||||
] | |||||
); | |||||
} elseif ($settingType == 'select') { | |||||
$form->add( | |||||
'text', | |||||
ChoiceType::class, | |||||
[ | |||||
'label' => $label, | |||||
'expanded' => false, | |||||
'multiple' => false, | |||||
'placeholder' => false, | |||||
'choices' => $setting['choices'] | |||||
] | |||||
); | |||||
} elseif ($settingType == 'radio') { | |||||
$form->add( | |||||
'text', | |||||
ChoiceType::class, | |||||
[ | |||||
'label' => $label, | |||||
'expanded' => true, | |||||
'multiple' => false, | |||||
'placeholder' => false, | |||||
'choices' => $setting['choices'] | |||||
] | |||||
); | |||||
} | |||||
elseif ($settingType == 'date') { | |||||
$form->add( | |||||
'date', | |||||
DateType::class, | |||||
[ | |||||
'label' => $label, | |||||
'widget' => 'single_text', | |||||
] | |||||
); | |||||
} | |||||
elseif ($settingType == 'time') { | |||||
$form->add( | |||||
'date', | |||||
TimeType::class, | |||||
[ | |||||
'label' => $label, | |||||
'input' => 'datetime', | |||||
'widget' => 'single_text', | |||||
] | |||||
); | |||||
} | |||||
elseif ($settingType == 'file' || $settingType == 'image') { | |||||
$form->add( | |||||
'file', | |||||
FileManagerType::class, | |||||
[ | |||||
'label' => $label, | |||||
'attr' => [ | |||||
'type' => $settingType | |||||
] | |||||
] | |||||
); | |||||
} | |||||
if(isset($settingDefinition) && $settingDefinition) { | |||||
$this->buildFormSetting($label, $form, $settingDefinition, $settingEntity); | |||||
} | } | ||||
} | } | ||||
} | } |
<?php | |||||
namespace Lc\CaracoleBundle\Repository\Reminder; | |||||
use Lc\CaracoleBundle\Repository\RepositoryTrait; | |||||
use Lc\SovBundle\Model\Reminder\ReminderInterface; | |||||
use Lc\SovBundle\Repository\Reminder\ReminderRepository as SovReminderRepository; | |||||
/** | |||||
* @method ReminderInterface|null find($id, $lockMode = null, $lockVersion = null) | |||||
* @method ReminderInterface|null findOneBy(array $criteria, array $orderBy = null) | |||||
* @method ReminderInterface[] findAll() | |||||
* @method ReminderInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |||||
*/ | |||||
class ReminderRepository extends SovReminderRepository | |||||
{ | |||||
use RepositoryTrait; | |||||
} |
carac_admin_setting_section: | carac_admin_setting_section: | ||||
path: /admin/setting/section | path: /admin/setting/section | ||||
controller: Lc\CaracoleBundle\Controller\Setting\SettingAdminController::manageSection | controller: Lc\CaracoleBundle\Controller\Setting\SettingAdminController::manageSection | ||||
carac_admin_setting_global: | |||||
path: /admin/setting/global2 | |||||
controller: Lc\CaracoleBundle\Controller\Setting\SettingAdminController::manageGlobal |
{% embed '@LcSov/adminlte/embed/tabs/tabs.html.twig' %} | |||||
{# items menu #} | |||||
{% import '@LcSov/adminlte/macro/tabs.html.twig' as mtabs %} | |||||
{% block menu_items %} | |||||
{% for index, category in setting_definition.getCategories() %} | |||||
{{ mtabs.menu_item(category, loop.first, ('setting_definition.'~trans_category~'.categories.'~category)|trans({}, 'admin')) }} | |||||
{% endfor %} | |||||
{% endblock %} | |||||
{# content #} | |||||
{% block content %} | |||||
{% form_theme form '@LcSov/adminlte/crud/form_theme.html.twig' %} | |||||
{{ form_start(form) }} | |||||
{# panes #} | |||||
{% for index, category in setting_definition.getCategories() %} | |||||
{% embed '@LcSov/adminlte/embed/tabs/pane.html.twig' %} | |||||
{% block class %}{{ index == 0 ? 'active' }}{% endblock %} | |||||
{% block id %}{{ category }}{% endblock %} | |||||
{% block content %} | |||||
{% set count = 0 %} | |||||
{% for name, setting in setting_definition.getSettingsByCategory(category) %} | |||||
{% for child in form.settings %} | |||||
{% if child.children.name.vars.value == name %} | |||||
{{ form_widget(child) }} | |||||
{% set count = count + 1 %} | |||||
{% endif %} | |||||
{% endfor %} | |||||
{% endfor %} | |||||
{% if count == 0 %} | |||||
{% import '@LcSov/adminlte/macro/callout.html.twig' as mcallout %} | |||||
{{ mcallout.callout_warning('Aucun paramètre disponible dans cet onglet.') }} | |||||
{% endif %} | |||||
{% endblock %} | |||||
{% endembed %} | |||||
{% endfor %} | |||||
{# form footer #} | |||||
{% embed '@LcSov/adminlte/embed/form_footer.html.twig' %} | |||||
{% block width %}12{% endblock %} | |||||
{% block content %} | |||||
{{ form_widget(form.submit) }} | |||||
{% endblock %} | |||||
{% endembed %} | |||||
{{ form_end(form) }} | |||||
{% endblock %} | |||||
{% endembed %} |
{% extends '@LcCaracole/adminlte/layout.html.twig' %} | |||||
{% block content_title %} | |||||
Paramètres globaux | |||||
{% endblock %} | |||||
{% block main %} | |||||
{% set trans_category = 'global' %} | |||||
{% include '@LcSov/admin/setting/form.html.twig' %} | |||||
{% endblock %} |
{% extends '@LcCaracole/adminlte/layout.html.twig' %} | {% extends '@LcCaracole/adminlte/layout.html.twig' %} | ||||
{% block content_title %} | {% block content_title %} | ||||
Paramètres globaux | |||||
Paramètres marchand | |||||
{% endblock %} | {% endblock %} | ||||
{% block main %} | {% block main %} | ||||
{% set trans_category = 'merchant' %} | {% set trans_category = 'merchant' %} | ||||
{% include '@LcCaracole/admin/setting/form.html.twig' %} | |||||
{% include '@LcSov/admin/setting/form.html.twig' %} | |||||
{% endblock %} | {% endblock %} |
{% block content_title %} | {% block content_title %} | ||||
{% set current_section = resolver.getCurrent() %} | {% set current_section = resolver.getCurrent() %} | ||||
Paramètres de section > {{ current_section.title }} | |||||
Paramètres section > {{ current_section.title }} | |||||
{% endblock %} | {% endblock %} | ||||
{% block main %} | {% block main %} | ||||
{% set trans_category = 'section' %} | {% set trans_category = 'section' %} | ||||
{% include '@LcCaracole/admin/setting/form.html.twig' %} | |||||
{% include '@LcSov/admin/setting/form.html.twig' %} | |||||
{% endblock %} | {% endblock %} |