<?php | |||||
namespace Lc\ShopBundle\Context; | |||||
interface ImageInterface | |||||
{ | |||||
} |
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | ||||
use FOS\UserBundle\Model\UserManagerInterface; | use FOS\UserBundle\Model\UserManagerInterface; | ||||
use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface; | use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface; | ||||
use Lc\ShopBundle\Context\ImageInterface; | |||||
use Lc\ShopBundle\Context\MerchantInterface; | use Lc\ShopBundle\Context\MerchantInterface; | ||||
use Lc\ShopBundle\Context\ReminderInterface; | use Lc\ShopBundle\Context\ReminderInterface; | ||||
use Lc\ShopBundle\Context\SeoInterface; | use Lc\ShopBundle\Context\SeoInterface; | ||||
} | } | ||||
break; | break; | ||||
case 'association' : | case 'association' : | ||||
$filter = $this->filtersForm->get($field['property'])->getData(); | $filter = $this->filtersForm->get($field['property'])->getData(); | ||||
if ($filter !== null) { | if ($filter !== null) { | ||||
if ($field['type_options']['multiple']) { | if ($field['type_options']['multiple']) { | ||||
} else { | } else { | ||||
$queryBuilder->andWhere('entity.' . $field['property'] . ' = :' . $field['property'] . ''); | $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; | break; | ||||
case 'datetime': | case 'datetime': | ||||
$newEntity = clone $entity ; | $newEntity = clone $entity ; | ||||
if($newEntity instanceof ImageInterface){ | |||||
$newEntity->setImage(null); | |||||
} | |||||
$this->em->persist($newEntity) ; | $this->em->persist($newEntity) ; | ||||
$this->em->flush() ; | $this->em->flush() ; | ||||
use App\Entity\Product; | use App\Entity\Product; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | ||||
use Lc\ShopBundle\Context\ImageInterface; | |||||
use Lc\ShopBundle\Context\OrderShopInterface; | use Lc\ShopBundle\Context\OrderShopInterface; | ||||
use Lc\ShopBundle\Context\ProductCategoryInterface; | use Lc\ShopBundle\Context\ProductCategoryInterface; | ||||
use Lc\ShopBundle\Context\ProductFamilyInterface; | use Lc\ShopBundle\Context\ProductFamilyInterface; | ||||
if ($easyadmin['entity']['name'] == "ProductFamily") { | if ($easyadmin['entity']['name'] == "ProductFamily") { | ||||
$this->processProducts($newProductFamily, true); | $this->processProducts($newProductFamily, true); | ||||
} | } | ||||
if($newProductFamily instanceof ImageInterface){ | |||||
$newProductFamily->setImage(null); | |||||
} | |||||
$this->em->persist($newProductFamily); | $this->em->persist($newProductFamily); | ||||
$this->em->flush(); | $this->em->flush(); | ||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Gedmo\Mapping\Annotation as Gedmo; | use Gedmo\Mapping\Annotation as Gedmo; | ||||
use Lc\ShopBundle\Context\ImageInterface; | |||||
use Lc\ShopBundle\Context\SeoInterface; | use Lc\ShopBundle\Context\SeoInterface; | ||||
use Lc\ShopBundle\Context\SluggableInterface; | use Lc\ShopBundle\Context\SluggableInterface; | ||||
use Lc\ShopBundle\Context\SortableInterface; | use Lc\ShopBundle\Context\SortableInterface; | ||||
* @ORM\MappedSuperclass | * @ORM\MappedSuperclass | ||||
* @Vich\Uploadable | * @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; | use SortableTrait; | ||||
use SluggableTrait; | use SluggableTrait; | ||||
use ImageTrait; | |||||
use SeoTrait; | use SeoTrait; | ||||
/** | /** | ||||
*/ | */ | ||||
protected $description; | 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) | * @ORM\Column(type="string", length=255, nullable=true) | ||||
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 | public function getTitle(): ?string | ||||
{ | { | ||||
} | } | ||||
public function getImage(): ?string | |||||
{ | |||||
return $this->image; | |||||
} | |||||
public function setImage(?string $image): self | |||||
{ | |||||
$this->image = $image; | |||||
return $this; | |||||
} | |||||
public function getDevAlias(): ?string | public function getDevAlias(): ?string | ||||
{ | { |
<?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; | |||||
} | |||||
} |
{ | { | ||||
return $this->oldUrls; | return $this->oldUrls; | ||||
} | } | ||||
} | |||||
} |
{% if value|length > 0 %} | |||||
<span class="badge badge-success"> | |||||
{{ value|length }} compléments | |||||
</span> | |||||
{% else %} | |||||
<span class="badge badge-danger"> | |||||
non | |||||
</span> | |||||
{% endif %} |