|
|
@@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
namespace Lc\CaracoleBundle\Form\Section; |
|
|
|
|
|
|
|
use App\Repository\Section\SectionStore; |
|
|
|
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; |
|
|
|
use Lc\CaracoleBundle\Repository\Section\SectionRepository; |
|
|
|
use Lc\CaracoleBundle\Resolver\MerchantResolver; |
|
|
@@ -20,53 +21,86 @@ use Symfony\Component\OptionsResolver\OptionsResolver; |
|
|
|
|
|
|
|
class SwitchSectionFormType extends AbstractType |
|
|
|
{ |
|
|
|
protected EntityManager $em; |
|
|
|
protected TranslatorAdmin $translatorAdmin; |
|
|
|
protected SectionStore $sectionStore; |
|
|
|
protected SectionResolver $sectionResolver; |
|
|
|
protected MerchantResolver $merchantResolver; |
|
|
|
protected SectionSolver $sectionSolver; |
|
|
|
|
|
|
|
public function __construct( |
|
|
|
EntityManager $em, |
|
|
|
TranslatorAdmin $translatorAdmin, |
|
|
|
SectionResolver $sectionResolver, |
|
|
|
SectionSolver $sectionSolver |
|
|
|
) { |
|
|
|
$this->em = $em; |
|
|
|
TranslatorAdmin $translatorAdmin, |
|
|
|
SectionStore $sectionStore, |
|
|
|
SectionResolver $sectionResolver, |
|
|
|
MerchantResolver $merchantResolver, |
|
|
|
SectionSolver $sectionSolver |
|
|
|
) |
|
|
|
{ |
|
|
|
$this->translatorAdmin = $translatorAdmin; |
|
|
|
$this->sectionResolver = $sectionResolver; |
|
|
|
$this->sectionStore = $sectionStore; |
|
|
|
$this->merchantResolver = $merchantResolver; |
|
|
|
$this->sectionSolver = $sectionSolver; |
|
|
|
} |
|
|
|
|
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options) |
|
|
|
{ |
|
|
|
$section = $options['section']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $builder->add( |
|
|
|
// 'id_section', |
|
|
|
// HiddenType::class, |
|
|
|
// [ |
|
|
|
// 'data' => $section ? $section->getId() : null |
|
|
|
// ] |
|
|
|
// ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$currentSection = $this->sectionResolver->getCurrent(); |
|
|
|
$sections = $this->sectionStore->setMerchant($this->merchantResolver->getCurrent())->getOnline(); |
|
|
|
|
|
|
|
$styleButton = ''; |
|
|
|
$classButton = 'btn-section'; |
|
|
|
if (null == $currentSection) { |
|
|
|
$classButton .= ' btn-section-current ' . $this->sectionSolver->getHtmlClass($currentSection); |
|
|
|
} |
|
|
|
//TOUT afficher |
|
|
|
$builder->add( |
|
|
|
'id_section', |
|
|
|
HiddenType::class, |
|
|
|
[ |
|
|
|
'data' => $section ? $section->getId() : null |
|
|
|
'switch_all', |
|
|
|
SubmitType::class, |
|
|
|
[ |
|
|
|
'label' => 'Tout afficher', |
|
|
|
'attr' => [ |
|
|
|
'class' => $classButton, |
|
|
|
'style' => $styleButton, |
|
|
|
'value' => null, |
|
|
|
] |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$styleButton = ''; |
|
|
|
$classButton = 'btn-section'; |
|
|
|
if ($section == $currentSection) { |
|
|
|
$classButton .= ' btn-section-current '.$this->sectionSolver->getHtmlClass($currentSection); |
|
|
|
} |
|
|
|
|
|
|
|
$builder->add( |
|
|
|
'submit', |
|
|
|
foreach ($sections as $section) { |
|
|
|
$styleButton = ''; |
|
|
|
$classButton = 'btn-section'; |
|
|
|
if ($section == $currentSection) { |
|
|
|
$classButton .= ' btn-section-current ' . $this->sectionSolver->getHtmlClass($currentSection); |
|
|
|
} |
|
|
|
|
|
|
|
$builder->add( |
|
|
|
'switch_'.$section->getSlug(), |
|
|
|
SubmitType::class, |
|
|
|
[ |
|
|
|
'label' => $section ? $section->getTitle() : 'Tout afficher', |
|
|
|
'attr' => [ |
|
|
|
'class' => $classButton, |
|
|
|
'style' => $styleButton, |
|
|
|
] |
|
|
|
'label' => $section->getTitle(), |
|
|
|
'attr' => [ |
|
|
|
'class' => $classButton, |
|
|
|
'style' => $styleButton, |
|
|
|
'value' => $section->getId(), |
|
|
|
] |
|
|
|
] |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -75,9 +109,9 @@ class SwitchSectionFormType extends AbstractType |
|
|
|
public function configureOptions(OptionsResolver $resolver) |
|
|
|
{ |
|
|
|
$resolver->setDefaults( |
|
|
|
[ |
|
|
|
'section' => null, |
|
|
|
] |
|
|
|
[ |
|
|
|
'section' => null, |
|
|
|
] |
|
|
|
); |
|
|
|
} |
|
|
|
|