Browse Source

Correctif position catégories

feature/export_comptable
Guillaume 4 years ago
parent
commit
b262870239
1 changed files with 13 additions and 7 deletions
  1. +13
    -7
      ShopBundle/EventSubscriber/EditEventSubscriber.php

+ 13
- 7
ShopBundle/EventSubscriber/EditEventSubscriber.php View File

@@ -67,12 +67,14 @@ class EditEventSubscriber implements EventSubscriberInterface
return $entity;
}

private function setSortableProperty($entity, $entityRepo){
private function setSortableProperty($entity, $entityRepo)
{
if ($entity instanceof TreeInterface) {
if ($entity->getParent()) {
$total = $entityRepo->count(array('status' => 1, 'parent' => $entity->getParent()->getId()));
$entity->setPosition($entity->getParent()->getId() . '_' . $total);
} else {
$entity->setPosition((float) $entity->getParent()->getId() . '.' . str_pad($total, 2, '0', STR_PAD_LEFT));
}
else {
if ($entity instanceof FilterMerchantInterface) {
$total = $entityRepo->count(array('status' => 1, 'parent' => null, 'merchant' => $this->merchantUtils->getMerchantCurrent()));
}else{
@@ -80,10 +82,12 @@ class EditEventSubscriber implements EventSubscriberInterface
}
$entity->setPosition($total);
}
} else {
}
else {
if ($entity instanceof FilterMerchantInterface) {
$total = $entityRepo->count(array('status' => 1, 'merchant' => $this->merchantUtils->getMerchantCurrent()));
}else{
}
else {
$total = $entityRepo->count(array('status' => 1));
}
$entity->setPosition($total);
@@ -91,11 +95,13 @@ class EditEventSubscriber implements EventSubscriberInterface
return $entity;
}

private function setMerchantProperty($entity){
private function setMerchantProperty($entity)
{
$entity->setMerchant($this->merchantUtils->getMerchantCurrent());
}

private function setMultipleMerchantProperty($entity){
private function setMultipleMerchantProperty($entity)
{
if ($entity->getMerchants()->isEmpty()) {
$entity->addMerchant($this->merchantUtils->getMerchantCurrent());
}

Loading…
Cancel
Save