|
|
|
|
|
|
|
|
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()); |
|
|
} |
|
|
} |