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

return $entity; return $entity;
} }


private function setSortableProperty($entity, $entityRepo){
private function setSortableProperty($entity, $entityRepo)
{
if ($entity instanceof TreeInterface) { if ($entity instanceof TreeInterface) {
if ($entity->getParent()) { if ($entity->getParent()) {
$total = $entityRepo->count(array('status' => 1, 'parent' => $entity->getParent()->getId())); $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) { if ($entity instanceof FilterMerchantInterface) {
$total = $entityRepo->count(array('status' => 1, 'parent' => null, 'merchant' => $this->merchantUtils->getMerchantCurrent())); $total = $entityRepo->count(array('status' => 1, 'parent' => null, 'merchant' => $this->merchantUtils->getMerchantCurrent()));
}else{ }else{
} }
$entity->setPosition($total); $entity->setPosition($total);
} }
} else {
}
else {
if ($entity instanceof FilterMerchantInterface) { if ($entity instanceof FilterMerchantInterface) {
$total = $entityRepo->count(array('status' => 1, 'merchant' => $this->merchantUtils->getMerchantCurrent())); $total = $entityRepo->count(array('status' => 1, 'merchant' => $this->merchantUtils->getMerchantCurrent()));
}else{
}
else {
$total = $entityRepo->count(array('status' => 1)); $total = $entityRepo->count(array('status' => 1));
} }
$entity->setPosition($total); $entity->setPosition($total);
return $entity; return $entity;
} }


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


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

Loading…
Cancel
Save