@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Context; | |||
interface ImageInterface | |||
{ | |||
} |
@@ -8,6 +8,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Controller\EasyAdminController; | |||
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | |||
use FOS\UserBundle\Model\UserManagerInterface; | |||
use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface; | |||
use Lc\ShopBundle\Context\ImageInterface; | |||
use Lc\ShopBundle\Context\MerchantInterface; | |||
use Lc\ShopBundle\Context\ReminderInterface; | |||
use Lc\ShopBundle\Context\SeoInterface; | |||
@@ -190,6 +191,7 @@ class AdminController extends EasyAdminController | |||
} | |||
break; | |||
case 'association' : | |||
$filter = $this->filtersForm->get($field['property'])->getData(); | |||
if ($filter !== null) { | |||
if ($field['type_options']['multiple']) { | |||
@@ -197,7 +199,11 @@ class AdminController extends EasyAdminController | |||
} else { | |||
$queryBuilder->andWhere('entity.' . $field['property'] . ' = :' . $field['property'] . ''); | |||
} | |||
$queryBuilder->setParameter($field['property'], $filter); | |||
if($filter instanceof TreeInterface && $filter->getParent() == null) { | |||
$queryBuilder->setParameter($field['property'], array_merge(array($filter), $filter->getChildrens()->toArray())); | |||
}else{ | |||
$queryBuilder->setParameter($field['property'], $filter); | |||
} | |||
} | |||
break; | |||
case 'datetime': | |||
@@ -593,6 +599,10 @@ class AdminController extends EasyAdminController | |||
$newEntity = clone $entity ; | |||
if($newEntity instanceof ImageInterface){ | |||
$newEntity->setImage(null); | |||
} | |||
$this->em->persist($newEntity) ; | |||
$this->em->flush() ; | |||
@@ -4,6 +4,7 @@ namespace Lc\ShopBundle\Controller\Backend; | |||
use App\Entity\Product; | |||
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | |||
use Lc\ShopBundle\Context\ImageInterface; | |||
use Lc\ShopBundle\Context\OrderShopInterface; | |||
use Lc\ShopBundle\Context\ProductCategoryInterface; | |||
use Lc\ShopBundle\Context\ProductFamilyInterface; | |||
@@ -406,6 +407,11 @@ class ProductFamilyController extends AdminController | |||
if ($easyadmin['entity']['name'] == "ProductFamily") { | |||
$this->processProducts($newProductFamily, true); | |||
} | |||
if($newProductFamily instanceof ImageInterface){ | |||
$newProductFamily->setImage(null); | |||
} | |||
$this->em->persist($newProductFamily); | |||
$this->em->flush(); | |||
@@ -4,6 +4,7 @@ namespace Lc\ShopBundle\Model; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Gedmo\Mapping\Annotation as Gedmo; | |||
use Lc\ShopBundle\Context\ImageInterface; | |||
use Lc\ShopBundle\Context\SeoInterface; | |||
use Lc\ShopBundle\Context\SluggableInterface; | |||
use Lc\ShopBundle\Context\SortableInterface; | |||
@@ -15,7 +16,7 @@ use Vich\UploaderBundle\Mapping\Annotation as Vich; | |||
* @ORM\MappedSuperclass | |||
* @Vich\Uploadable | |||
*/ | |||
abstract class AbstractDocumentEntity extends AbstractEntity implements StatusInterface, SortableInterface, SluggableInterface, SeoInterface | |||
abstract class AbstractDocumentEntity extends AbstractEntity implements StatusInterface, SortableInterface, SluggableInterface, SeoInterface, ImageInterface | |||
{ | |||
use SortableTrait; | |||
@@ -23,6 +24,8 @@ abstract class AbstractDocumentEntity extends AbstractEntity implements StatusIn | |||
use SluggableTrait; | |||
use ImageTrait; | |||
use SeoTrait; | |||
/** | |||
@@ -35,16 +38,7 @@ abstract class AbstractDocumentEntity extends AbstractEntity implements StatusIn | |||
*/ | |||
protected $description; | |||
/** | |||
* @ORM\Column(type="string", length=255, nullable=true) | |||
*/ | |||
protected $image; | |||
/** | |||
* @Vich\UploadableField(mapping="images", fileNameProperty="image") | |||
* @var File | |||
*/ | |||
protected $imageFile; | |||
/** | |||
* @ORM\Column(type="string", length=255, nullable=true) | |||
@@ -54,23 +48,6 @@ abstract class AbstractDocumentEntity extends AbstractEntity implements StatusIn | |||
public function setImageFile(File $image = null) | |||
{ | |||
$this->imageFile = $image; | |||
// VERY IMPORTANT: | |||
// It is required that at least one field changes if you are using Doctrine, | |||
// otherwise the event listeners won't be called and the file is lost | |||
if ($image) { | |||
// if 'updatedAt' is not defined in your entity, use another property | |||
$this->updatedAt = new \DateTime('now'); | |||
} | |||
} | |||
public function getImageFile() | |||
{ | |||
return $this->imageFile; | |||
} | |||
public function getTitle(): ?string | |||
{ | |||
@@ -98,17 +75,6 @@ abstract class AbstractDocumentEntity extends AbstractEntity implements StatusIn | |||
} | |||
public function getImage(): ?string | |||
{ | |||
return $this->image; | |||
} | |||
public function setImage(?string $image): self | |||
{ | |||
$this->image = $image; | |||
return $this; | |||
} | |||
public function getDevAlias(): ?string | |||
{ |
@@ -0,0 +1,53 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Model; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Symfony\Component\HttpFoundation\File\File; | |||
trait ImageTrait | |||
{ | |||
/** | |||
* @ORM\Column(type="string", length=255, nullable=true) | |||
*/ | |||
protected $image; | |||
/** | |||
* @Vich\UploadableField(mapping="images", fileNameProperty="image") | |||
* @var File | |||
*/ | |||
protected $imageFile; | |||
public function setImageFile(File $image = null) | |||
{ | |||
$this->imageFile = $image; | |||
// VERY IMPORTANT: | |||
// It is required that at least one field changes if you are using Doctrine, | |||
// otherwise the event listeners won't be called and the file is lost | |||
if ($image) { | |||
// if 'updatedAt' is not defined in your entity, use another property | |||
$this->updatedAt = new \DateTime('now'); | |||
} | |||
} | |||
public function getImageFile() | |||
{ | |||
return $this->imageFile; | |||
} | |||
public function getImage(): ?string | |||
{ | |||
return $this->image; | |||
} | |||
public function setImage(?string $image): self | |||
{ | |||
$this->image = $image; | |||
return $this; | |||
} | |||
} |
@@ -60,4 +60,4 @@ trait SeoTrait | |||
{ | |||
return $this->oldUrls; | |||
} | |||
} | |||
} |
@@ -0,0 +1,9 @@ | |||
{% if value|length > 0 %} | |||
<span class="badge badge-success"> | |||
{{ value|length }} compléments | |||
</span> | |||
{% else %} | |||
<span class="badge badge-danger"> | |||
non | |||
</span> | |||
{% endif %} |