Browse Source

Correctifs backoffice

feature/export_comptable
Fab 4 years ago
parent
commit
4ea86affe5
7 changed files with 94 additions and 40 deletions
  1. +10
    -0
      ShopBundle/Context/ImageInterface.php
  2. +11
    -1
      ShopBundle/Controller/Backend/AdminController.php
  3. +6
    -0
      ShopBundle/Controller/Backend/ProductFamilyController.php
  4. +4
    -38
      ShopBundle/Model/AbstractDocumentEntity.php
  5. +53
    -0
      ShopBundle/Model/ImageTrait.php
  6. +1
    -1
      ShopBundle/Model/SeoTrait.php
  7. +9
    -0
      ShopBundle/Resources/views/backend/order/list-fields/field-complementary.html.twig

+ 10
- 0
ShopBundle/Context/ImageInterface.php View File

<?php

namespace Lc\ShopBundle\Context;

interface ImageInterface
{



}

+ 11
- 1
ShopBundle/Controller/Backend/AdminController.php View File

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() ;



+ 6
- 0
ShopBundle/Controller/Backend/ProductFamilyController.php View File



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();



+ 4
- 38
ShopBundle/Model/AbstractDocumentEntity.php View File



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
{ {

+ 53
- 0
ShopBundle/Model/ImageTrait.php View File

<?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;
}


}

+ 1
- 1
ShopBundle/Model/SeoTrait.php View File

{ {
return $this->oldUrls; return $this->oldUrls;
} }
}
}

+ 9
- 0
ShopBundle/Resources/views/backend/order/list-fields/field-complementary.html.twig View File

{% if value|length > 0 %}
<span class="badge badge-success">
{{ value|length }} compléments
</span>
{% else %}
<span class="badge badge-danger">
non
</span>
{% endif %}

Loading…
Cancel
Save