Fab 4 years ago
parent
commit
3edb527000
1 changed files with 18 additions and 14 deletions
  1. +18
    -14
      ShopBundle/Controller/Admin/AdminController.php

+ 18
- 14
ShopBundle/Controller/Admin/AdminController.php View File

public function updateEntity($entity) public function updateEntity($entity)
{ {
$this->setUpdated($entity); $this->setUpdated($entity);
$this->setAddressCreatedBy($entity) ;
parent::updateEntity($entity); parent::updateEntity($entity);
} }


} }
} }



if (method_exists($entity, 'setCreatedBy')) { if (method_exists($entity, 'setCreatedBy')) {
$entity->setCreatedBy($this->security->getUser()); $entity->setCreatedBy($this->security->getUser());
} }




if (method_exists($entity, 'getAddress') && $entity->getAddress()) {
$entity->getAddress()->setCreatedBy($this->security->getUser());
$entity->getAddress()->setCreatedAt(new \DateTime());
}

if (method_exists($entity, 'getAddresses')
&& $entity->getAddresses() && count($entity->getAddresses()) > 0) {
foreach($entity->getAddresses() as $address) {
$address->setCreatedBy($this->security->getUser()) ;
$address->setCreatedAt(new \DateTime()) ;
}
}

$this->setUpdated($entity); $this->setUpdated($entity);
$this->setAddressCreatedBy($entity) ;


parent::persistEntity($entity); parent::persistEntity($entity);
} }


public function setAddressCreatedBy($entity)
{
if (method_exists($entity, 'getAddress') && $entity->getAddress()) {
$entity->getAddress()->setCreatedBy($this->security->getUser());
$entity->getAddress()->setCreatedAt(new \DateTime());
}

if (method_exists($entity, 'getAddresses')
&& $entity->getAddresses() && count($entity->getAddresses()) > 0) {
foreach($entity->getAddresses() as $address) {
$address->setCreatedBy($this->security->getUser()) ;
$address->setCreatedAt(new \DateTime()) ;
}
}
}

public function setUpdated($entity) public function setUpdated($entity)
{ {



Loading…
Cancel
Save