@@ -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; |
@@ -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 |
@@ -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 | |||
{ |
@@ -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 | |||
{ | |||
@@ -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; |
@@ -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' | |||
] | |||
); | |||
} | |||
} |
@@ -1,8 +0,0 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Model\Common; | |||
interface TaxRateInterface | |||
{ | |||
} |
@@ -1,8 +0,0 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Model\Common ; | |||
interface UnitInterface | |||
{ | |||
} |
@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Model\Config; | |||
interface TaxRateInterface | |||
{ | |||
} |
@@ -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; |
@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Model\Config ; | |||
interface UnitInterface | |||
{ | |||
} |
@@ -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; |
@@ -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; |
@@ -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; | |||
/** |
@@ -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) |
@@ -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> |
@@ -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(); | |||
} | |||
} |