|
|
@@ -125,9 +125,14 @@ class AdminController extends EasyAdminController |
|
|
|
|
|
|
|
protected function removeEntity($entity) |
|
|
|
{ |
|
|
|
$entity->setStatus(-1); |
|
|
|
$this->em->persist($entity); |
|
|
|
$this->em->flush(); |
|
|
|
if(method_exists($entity, 'setStatus')) { |
|
|
|
$entity->setStatus(-1); |
|
|
|
$this->em->persist($entity); |
|
|
|
$this->em->flush(); |
|
|
|
} |
|
|
|
else { |
|
|
|
parent::removeEntity($entity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function updateEntity($entity) |
|
|
@@ -342,21 +347,38 @@ class AdminController extends EasyAdminController |
|
|
|
$form = $event->getForm(); |
|
|
|
$allChilds = $form->all() ; |
|
|
|
foreach($allChilds as $child) { |
|
|
|
|
|
|
|
$type = $child->getConfig()->getType()->getInnerType() ; |
|
|
|
|
|
|
|
if($type instanceof EntityType) { |
|
|
|
$attributes = $child->getConfig()->getAttributes() ; |
|
|
|
$passedOptions = $attributes['data_collector/passed_options'] ; |
|
|
|
$classImplements = class_implements($passedOptions['class']) ; |
|
|
|
|
|
|
|
if(in_array('App\Context\FilterHubInterface', $classImplements)) { |
|
|
|
if(in_array('App\Context\FilterHubInterface', $classImplements) || |
|
|
|
in_array('Lc\ShopBundle\Context\FilterMerchantInterface', $classImplements)) { |
|
|
|
|
|
|
|
$propertyMerchant = 'merchant' ; |
|
|
|
if(in_array('App\Context\FilterHubInterface', $classImplements)) { |
|
|
|
$propertyMerchant = 'hub' ; |
|
|
|
} |
|
|
|
|
|
|
|
$form->add($child->getName(), EntityType::class, array( |
|
|
|
'class' => $this->em->getClassMetadata($passedOptions['class'])->getName(), |
|
|
|
'label' => $passedOptions['label'], |
|
|
|
'query_builder' => function (EntityRepository $repo) { |
|
|
|
return $repo->createQueryBuilder('e') |
|
|
|
->where('e.hub = :currentMerchant') |
|
|
|
->setParameter(':currentMerchant', $this->getUser()->getMerchant()->getId()); |
|
|
|
'placeholder' => '--', |
|
|
|
'query_builder' => function (EntityRepository $repo) use ($passedOptions, $propertyMerchant) { |
|
|
|
$queryBuilder = $repo->createQueryBuilder('e') ; |
|
|
|
$propertyMerchant = 'e.'.$propertyMerchant ; |
|
|
|
|
|
|
|
if($passedOptions['class'] == 'App\Entity\PointSale') { |
|
|
|
$queryBuilder->where(':currentMerchant MEMBER OF '.$propertyMerchant) ; |
|
|
|
} |
|
|
|
else { |
|
|
|
$queryBuilder->where($propertyMerchant.' = :currentMerchant') ; |
|
|
|
} |
|
|
|
|
|
|
|
$queryBuilder->setParameter(':currentMerchant', $this->getUser()->getMerchant()->getId()) ; |
|
|
|
return $queryBuilder ; |
|
|
|
}, |
|
|
|
'required' => $passedOptions['required'], |
|
|
|
) |