Sfoglia il codice sorgente

Merge branch 'develop' of https://forge.laclic.fr/Laclic/CaracoleBundle into develop

feature/ticket
Charly 3 anni fa
parent
commit
1d63073cc0
11 ha cambiato i file con 68 aggiunte e 172 eliminazioni
  1. +42
    -11
      Controller/Setting/SettingAdminController.php
  2. +1
    -0
      Definition/MerchantSettingDefinition.php
  3. +1
    -0
      EventSubscriber/SettingEventSubscriber.php
  4. +1
    -1
      EventSubscriber/User/UserRolesEventSubscriber.php
  5. +5
    -89
      Form/Setting/BaseSettingType.php
  6. +0
    -18
      Repository/Reminder/ReminderRepository.php
  7. +4
    -0
      Resources/config/routes.yaml
  8. +0
    -49
      Resources/views/admin/setting/form.html.twig
  9. +10
    -0
      Resources/views/admin/setting/global.html.twig
  10. +2
    -2
      Resources/views/admin/setting/merchant.html.twig
  11. +2
    -2
      Resources/views/admin/setting/section.html.twig

+ 42
- 11
Controller/Setting/SettingAdminController.php Vedi File

@@ -10,33 +10,41 @@ use Lc\CaracoleBundle\Form\Setting\SectionSettingsFormType;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver;
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 Symfony\Component\HttpFoundation\Request;

class SettingAdminController extends SovSettingController
{
protected $em;
protected $translatorAdmin;
protected $merchantResolver;
protected $merchantSettingDefinition;
protected $sectionResolver;
protected $sectionSettingDefinition;
protected $translatorAdmin;
protected $siteSettingDefinition;
protected $siteRepository;

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->translatorAdmin = $translatorAdmin;
$this->merchantResolver = $merchantResolver;
$this->sectionResolver = $sectionResolver;
$this->merchantSettingDefinition = $merchantSettingDefinition;
$this->sectionSettingDefinition = $sectionSettingDefinition;
$this->translatorAdmin = $translatorAdmin;
$this->siteSettingDefinition = $siteSettingDefinition;
$this->siteRepository = $siteRepository;
}

public function manageMerchant(Request $request)
@@ -66,7 +74,6 @@ class SettingAdminController extends SovSettingController
$entity = $resolver->getCurrent();

if ($entity) {

$form = $this->createForm($formClass, $entity);

$form->handleRequest($request);
@@ -88,4 +95,28 @@ class SettingAdminController extends SovSettingController
);
}
}

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()
]
);
}
}

+ 1
- 0
Definition/MerchantSettingDefinition.php Vedi File

@@ -2,6 +2,7 @@

namespace Lc\CaracoleBundle\Definition;

use Lc\SovBundle\Definition\AbstractSettingDefinition;

class MerchantSettingDefinition extends AbstractSettingDefinition implements MerchantSettingDefinitionInterface
{

+ 1
- 0
EventSubscriber/SettingEventSubscriber.php Vedi File

@@ -67,6 +67,7 @@ class SettingEventSubscriber implements EventSubscriberInterface
$this->sectionRepository->findAll(),
$this->sectionSettingFactory
);

}

public function initSettingsGeneric($type, $settings, $entities, $factory)

+ 1
- 1
EventSubscriber/User/UserRolesEventSubscriber.php Vedi File

@@ -46,7 +46,7 @@ class UserRolesEventSubscriber implements EventSubscriberInterface

public function setUserRolesFromKernelRequest(RequestEvent $event)
{
if (!$event->isMainRequest()) {
if (!$event->isMasterRequest()) {
return;
}
if ($this->setUserRoles($event->getRequest())) {

+ 5
- 89
Form/Setting/BaseSettingType.php Vedi File

@@ -20,8 +20,9 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
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 $merchantSettingDefinition;
@@ -63,96 +64,11 @@ abstract class BaseSettingType extends AbstractType
$transCategory = 'section' ;
$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);
}
}
}

+ 0
- 18
Repository/Reminder/ReminderRepository.php Vedi File

@@ -1,18 +0,0 @@
<?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;
}

+ 4
- 0
Resources/config/routes.yaml Vedi File

@@ -17,3 +17,7 @@ carac_admin_setting_merchant:
carac_admin_setting_section:
path: /admin/setting/section
controller: Lc\CaracoleBundle\Controller\Setting\SettingAdminController::manageSection

carac_admin_setting_global:
path: /admin/setting/global2
controller: Lc\CaracoleBundle\Controller\Setting\SettingAdminController::manageGlobal

+ 0
- 49
Resources/views/admin/setting/form.html.twig Vedi File

@@ -1,49 +0,0 @@

{% 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 %}

+ 10
- 0
Resources/views/admin/setting/global.html.twig Vedi File

@@ -0,0 +1,10 @@
{% 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 %}

+ 2
- 2
Resources/views/admin/setting/merchant.html.twig Vedi File

@@ -1,10 +1,10 @@
{% extends '@LcCaracole/adminlte/layout.html.twig' %}

{% block content_title %}
Paramètres globaux
Paramètres marchand
{% endblock %}

{% block main %}
{% set trans_category = 'merchant' %}
{% include '@LcCaracole/admin/setting/form.html.twig' %}
{% include '@LcSov/admin/setting/form.html.twig' %}
{% endblock %}

+ 2
- 2
Resources/views/admin/setting/section.html.twig Vedi File

@@ -2,10 +2,10 @@

{% block content_title %}
{% set current_section = resolver.getCurrent() %}
Paramètres de section &gt; {{ current_section.title }}
Paramètres section &gt; {{ current_section.title }}
{% endblock %}

{% block main %}
{% set trans_category = 'section' %}
{% include '@LcCaracole/admin/setting/form.html.twig' %}
{% include '@LcSov/admin/setting/form.html.twig' %}
{% endblock %}

Loading…
Annulla
Salva