Browse Source

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

feature/ticket
Fab 3 years ago
parent
commit
af61ad3233
17 changed files with 169 additions and 50 deletions
  1. +3
    -3
      Controller/AbstractAdminController.php
  2. +3
    -3
      Controller/Config/TaxRateAdminController.php
  3. +3
    -3
      Controller/Dashboard/DashboardAdminController.php
  4. +2
    -2
      Controller/User/GroupUserAdminController.php
  5. +4
    -4
      Doctrine/Extension/PriceTrait.php
  6. +37
    -0
      Form/Merchant/SwitchMerchantFormType.php
  7. +0
    -8
      Model/Common/TaxRateInterface.php
  8. +0
    -8
      Model/Common/UnitInterface.php
  9. +8
    -0
      Model/Config/TaxRateInterface.php
  10. +1
    -1
      Model/Config/TaxRateModel.php
  11. +8
    -0
      Model/Config/UnitInterface.php
  12. +2
    -2
      Model/Config/UnitModel.php
  13. +2
    -2
      Model/Merchant/MerchantModel.php
  14. +2
    -2
      Repository/Config/TaxRateRepository.php
  15. +2
    -2
      Repository/Config/UnitRepository.php
  16. +9
    -10
      Resources/views/adminlte/layout.html.twig
  17. +83
    -0
      Twig/TwigExtension.php

Controller/Admin/AbstractCrudController.php → Controller/AbstractAdminController.php View File

@@ -1,6 +1,6 @@
<?php

namespace Lc\CaracoleBundle\Controller\Admin;
namespace Lc\CaracoleBundle\Controller;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder;
@@ -11,7 +11,7 @@ use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Controller\Admin\AbstractCrudController as SovAbstractCrudController;
use Lc\SovBundle\Controller\AbstractAdminController as SovAbstractAdminController;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto;
use Lc\SovBundle\Doctrine\EntityManager;
@@ -20,7 +20,7 @@ use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

abstract class AbstractCrudController extends SovAbstractCrudController
abstract class AbstractAdminController extends SovAbstractAdminController
{
protected $session;
protected $request;

Controller/Common/TaxRateCrudController.php → Controller/Config/TaxRateAdminController.php View File

@@ -1,14 +1,14 @@
<?php

namespace Lc\CaracoleBundle\Controller\Common;
namespace Lc\CaracoleBundle\Controller\Config;

use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Controller\Admin\AbstractCrudController;
use Lc\CaracoleBundle\Controller\AbstractAdminController;

abstract class TaxRateCrudController extends AbstractCrudController
abstract class TaxRateAdminController extends AbstractAdminController
{

public function configureCrud(Crud $crud): Crud

Controller/Admin/DashboardController.php → Controller/Dashboard/DashboardAdminController.php View File

@@ -1,11 +1,11 @@
<?php

namespace Lc\CaracoleBundle\Controller\Admin;
namespace Lc\CaracoleBundle\Controller\Dashboard;

use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use Lc\SovBundle\Controller\Admin\DashboardController as SovDashboardController ;
use Lc\SovBundle\Controller\Dashboard\DashboardController as SovDashboardController ;

class DashboardController extends SovDashboardController
class DashboardAdminController extends SovDashboardController
{
public function configureCrud(): Crud
{

Controller/User/GroupUserCrudController.php → Controller/User/GroupUserAdminController.php View File

@@ -11,9 +11,9 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Controller\Admin\AbstractCrudController;
use Lc\CaracoleBundle\Controller\AbstractAdminController;

abstract class GroupUserCrudController extends AbstractCrudController
abstract class GroupUserAdminController extends AbstractAdminController
{



+ 4
- 4
Doctrine/Extension/PriceTrait.php View File

@@ -2,8 +2,8 @@

namespace Lc\CaracoleBundle\Doctrine\Extension;

use Lc\CaracoleBundle\Model\Common\TaxRateInterface;
use Lc\CaracoleBundle\Model\Common\UnitInterface;
use Lc\CaracoleBundle\Model\Config\TaxRateInterface;
use Lc\CaracoleBundle\Model\Config\UnitInterface;

trait PriceTrait
{
@@ -13,13 +13,13 @@ trait PriceTrait
protected $price;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Common\UnitInterface")
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Config\UnitInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $unit;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Common\TaxRateInterface")
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Config\TaxRateInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $taxRate;

+ 37
- 0
Form/Merchant/SwitchMerchantFormType.php View File

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

namespace Lc\CaracoleBundle\Form\Merchant;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\SovBundle\DataTransformer\FileManagerTypeToDataTransformer;
use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

class SwitchMerchantFormType extends AbstractType
{
protected $em;
protected $translatorAdmin;

public function __construct(EntityManager $em, TranslatorAdmin $translatorAdmin)
{
$this->em = $em;
$this->translatorAdmin = $translatorAdmin;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$entityName = $this->em->getEntityName(MerchantInterface::class);

$builder->add(
'merchants',
EntityType::class,
[
'class' => $entityName,
'choice_label' => 'title'
]
);
}
}

+ 0
- 8
Model/Common/TaxRateInterface.php View File

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

namespace Lc\CaracoleBundle\Model\Common;

interface TaxRateInterface
{

}

+ 0
- 8
Model/Common/UnitInterface.php View File

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

namespace Lc\CaracoleBundle\Model\Common ;

interface UnitInterface
{

}

+ 8
- 0
Model/Config/TaxRateInterface.php View File

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

namespace Lc\CaracoleBundle\Model\Config;

interface TaxRateInterface
{

}

Model/Common/TaxRateModel.php → Model/Config/TaxRateModel.php View File

@@ -1,6 +1,6 @@
<?php

namespace Lc\CaracoleBundle\Model\Common;
namespace Lc\CaracoleBundle\Model\Config;

use Doctrine\ORM\Mapping as ORM;
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;

+ 8
- 0
Model/Config/UnitInterface.php View File

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

namespace Lc\CaracoleBundle\Model\Config ;

interface UnitInterface
{

}

Model/Common/UnitModel.php → Model/Config/UnitModel.php View File

@@ -1,6 +1,6 @@
<?php

namespace Lc\CaracoleBundle\Model\Common;
namespace Lc\CaracoleBundle\Model\Config;

use Doctrine\ORM\Mapping as ORM;
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
@@ -36,7 +36,7 @@ abstract class UnitModel extends AbstractLightEntity
protected $coefficient;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Common\UnitInterface")
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Config\UnitInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $unitReference;

+ 2
- 2
Model/Merchant/MerchantModel.php View File

@@ -6,7 +6,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Common\TaxRateInterface;
use Lc\CaracoleBundle\Model\Config\TaxRateInterface;
use Lc\CaracoleBundle\Model\Credit\CreditConfigInterface;
use Lc\CaracoleBundle\Model\Newsletter\NewsletterInterface;
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
@@ -29,7 +29,7 @@ abstract class MerchantModel extends AbstractFullEntity
protected $creditConfig;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Common\TaxRateInterface")
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Config\TaxRateInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $taxRate;

Repository/Common/TaxRateRepository.php → Repository/Config/TaxRateRepository.php View File

@@ -1,8 +1,8 @@
<?php

namespace Lc\CaracoleBundle\Repository\Common;
namespace Lc\CaracoleBundle\Repository\Config;

use Lc\CaracoleBundle\Model\Common\TaxRateInterface;
use Lc\CaracoleBundle\Model\Config\TaxRateInterface;
use Lc\SovBundle\Repository\AbstractRepository;

/**

Repository/Common/UnitRepository.php → Repository/Config/UnitRepository.php View File

@@ -1,10 +1,10 @@
<?php

namespace Lc\CaracoleBundle\Repository\Common;
namespace Lc\CaracoleBundle\Repository\Config;

use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Lc\CaracoleBundle\Model\Common\UnitInterface;
use Lc\CaracoleBundle\Model\Config\UnitInterface;

/**
* @method UnitInterface|null find($id, $lockMode = null, $lockVersion = null)

+ 9
- 10
Resources/views/adminlte/layout.html.twig View File

@@ -5,19 +5,18 @@

<nav class="navbar navbar-expand navbar-light main-header">
<ul class="navbar-nav">
<li class="nav-item d-none d-sm-inline-block">
<a href="#" class="nav-link">Marché</a>
</li>
<li class="nav-item d-none d-sm-inline-block">
<a href="#" class="nav-link">Repas du midi</a>
</li>
<li class="nav-item d-none d-sm-inline-block">
<a href="#" class="nav-link">Retrait journée</a>
</li>
{% for section in carac_get_sections() %}
<li class="nav-item d-none d-sm-inline-block">
<a href="#" class="nav-link">{{ section.title }}</a>
</li>
{% endfor %}
</ul>
<ul class="navbar-nav ml-auto">
<li class="nav-item">
Switch merchant
{% set form_switch_merchant = carac_get_form_switch_merchhant() %}
{{ form_start(form_switch_merchant) }}
{{ form(form_switch_merchant) }}
{{ form_end(form_switch_merchant) }}
</li>
</ul>
</nav>

+ 83
- 0
Twig/TwigExtension.php View File

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

namespace Lc\CaracoleBundle\Twig;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Form\Merchant\SwitchMerchantFormType;
use Lc\CaracoleBundle\Repository\Merchant\MerchantRepository;
use Lc\CaracoleBundle\Repository\Section\SectionRepository;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

class TwigExtension extends AbstractExtension
{
protected $em;
protected $kernel;
protected $parameterBag;
protected $cacheManager;
protected $requestStack;
protected $router;
protected $translator;
protected $translatorAdmin;
protected $merchantRepository;
protected $sectionRepository;
protected $formFactory;

public function __construct(
KernelInterface $kernel,
ParameterBagInterface $parameterBag,
CacheManager $cacheManager,
EntityManagerInterface $entityManager,
RequestStack $requestStack,
UrlGeneratorInterface $router,
TranslatorInterface $translator,
TranslatorAdmin $translatorAdmin,
MerchantRepository $merchantRepository,
SectionRepository $sectionRepository,
FormFactoryInterface $formFactory
) {
$this->kernel = $kernel;
$this->parameterBag = $parameterBag;
$this->cacheManager = $cacheManager;
$this->em = $entityManager;
$this->requestStack = $requestStack;
$this->router = $router;
$this->translator = $translator;
$this->translatorAdmin = $translatorAdmin;
$this->merchantRepository = $merchantRepository;
$this->sectionRepository = $sectionRepository;
$this->formFactory = $formFactory;
}

public function getFunctions()
{
return array(
new TwigFunction('carac_get_sections', [$this, 'getSections']),
new TwigFunction('carac_get_form_switch_merchhant', [$this, 'getFormSwitchMerchant']),
);
}

public function getSections()
{
return $this->sectionRepository->findAll();
}

public function getMerchants()
{
return $this->merchantRepository->findAll();
}

public function getFormSwitchMerchant()
{
$form = $this->formFactory->create(SwitchMerchantFormType::class, null, ['action' => '#']);
return $form->createView();
}
}

Loading…
Cancel
Save