<?php | |||||
namespace Lc\ShopBundle\Controller\Admin; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\EasyAdminController; | |||||
use Symfony\Component\Security\Core\Security; | |||||
class AdminController extends EasyAdminController | |||||
{ | |||||
protected $security ; | |||||
public function __construct(Security $security) | |||||
{ | |||||
$this->security = $security ; | |||||
} | |||||
public function updateEntity($entity) | |||||
{ | |||||
$this->setUpdated($entity) ; | |||||
parent::updateEntity($entity); | |||||
} | |||||
public function persistEntity($entity) | |||||
{ | |||||
if (method_exists($entity, 'setCreatedAt')) { | |||||
$entity->setCreatedAt(new \DateTime()); | |||||
} | |||||
if (method_exists($entity, 'setCreatedAt')) { | |||||
$entity->setCreatedBy($this->security->getUser()); | |||||
} | |||||
$this->setUpdated($entity) ; | |||||
$entity->setPosition(0) ; | |||||
parent::persistEntity($entity); | |||||
} | |||||
public function setUpdated($entity) | |||||
{ | |||||
if (method_exists($entity, 'setUpdatedAt')) { | |||||
$entity->setUpdatedAt(new \DateTime()); | |||||
} | |||||
if (method_exists($entity, 'setUpdatedAt')) { | |||||
$entity->setUpdatedBy($this->security->getUser()); | |||||
} | |||||
} | |||||
} | |||||
<?php | |||||
namespace Lc\ShopBundle\Controller\Admin; | |||||
use Lc\ShopBundle\Controller\Admin\AdminController; | |||||
class TaxRateAdminController extends AdminController | |||||
{ | |||||
} |
/** | /** | ||||
* @ORM\Column(type="string", length=255) | * @ORM\Column(type="string", length=255) | ||||
*/ | */ | ||||
private $title; | |||||
protected $title; | |||||
/** | /** | ||||
* @ORM\Column(type="string", length=255) | * @ORM\Column(type="string", length=255) | ||||
* @Gedmo\Slug(fields={"title"}) | * @Gedmo\Slug(fields={"title"}) | ||||
*/ | */ | ||||
private $slug; | |||||
protected $slug; | |||||
/** | /** | ||||
* @ORM\Column(type="text", nullable=true) | * @ORM\Column(type="text", nullable=true) | ||||
*/ | */ | ||||
private $description; | |||||
protected $description; | |||||
/** | /** | ||||
* @ORM\Column(type="string", length=255, nullable=true) | * @ORM\Column(type="string", length=255, nullable=true) | ||||
*/ | */ | ||||
private $image; | |||||
protected $image; | |||||
/** | /** | ||||
* @ORM\Column(type="float") | * @ORM\Column(type="float") | ||||
*/ | */ | ||||
private $status; | |||||
protected $status; | |||||
/** | /** | ||||
* @ORM\Column(type="integer") | * @ORM\Column(type="integer") | ||||
* @Gedmo\SortablePosition() | * @Gedmo\SortablePosition() | ||||
*/ | */ | ||||
private $position; | |||||
protected $position; | |||||
public function getTitle(): ?string | public function getTitle(): ?string |