Ver código fonte

adminlte

reduction
Guillaume 4 anos atrás
pai
commit
e0bfee360d
3 arquivos alterados com 68 adições e 6 exclusões
  1. +52
    -0
      ShopBundle/Controller/Admin/AdminController.php
  2. +10
    -0
      ShopBundle/Controller/Admin/TaxRateAdminController.php
  3. +6
    -6
      ShopBundle/Model/AbstractDocumentEntity.php

+ 52
- 0
ShopBundle/Controller/Admin/AdminController.php Ver arquivo

@@ -0,0 +1,52 @@
<?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());
}
}

}


+ 10
- 0
ShopBundle/Controller/Admin/TaxRateAdminController.php Ver arquivo

@@ -0,0 +1,10 @@
<?php

namespace Lc\ShopBundle\Controller\Admin;

use Lc\ShopBundle\Controller\Admin\AdminController;

class TaxRateAdminController extends AdminController
{

}

+ 6
- 6
ShopBundle/Model/AbstractDocumentEntity.php Ver arquivo

@@ -14,34 +14,34 @@ abstract class AbstractDocumentEntity extends AbstractEntity
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
protected $title;

/**
* @ORM\Column(type="string", length=255)
* @Gedmo\Slug(fields={"title"})
*/
private $slug;
protected $slug;

/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
protected $description;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
protected $image;

/**
* @ORM\Column(type="float")
*/
private $status;
protected $status;

/**
* @ORM\Column(type="integer")
* @Gedmo\SortablePosition()
*/
private $position;
protected $position;


public function getTitle(): ?string

Carregando…
Cancelar
Salvar