Parcourir la source

Correctifs

develop
Guillaume il y a 3 ans
Parent
révision
4a2cd5ba9f
13 fichiers modifiés avec 218 ajouts et 41 suppressions
  1. +32
    -0
      ShopBundle/Event/EntityManager/EntityManagerEvent.php
  2. +35
    -0
      ShopBundle/Event/OrderShop/OrderShopChangeStatusEvent.php
  3. +105
    -0
      ShopBundle/Manager/EntityManager.php
  4. +0
    -8
      ShopBundle/Model/AbstractDocumentEntity.php
  5. +1
    -1
      ShopBundle/Model/OrderShop.php
  6. +0
    -1
      ShopBundle/Model/User.php
  7. +3
    -2
      ShopBundle/Repository/BaseRepository.php
  8. +6
    -1
      ShopBundle/Repository/OrderShopRepository.php
  9. +3
    -2
      ShopBundle/Repository/UserRepository.php
  10. +21
    -18
      ShopBundle/Resources/views/backend/default/block/macros.html.twig
  11. +3
    -1
      ShopBundle/Resources/views/backend/default/field/user.html.twig
  12. +8
    -6
      ShopBundle/Resources/views/backend/default/list.html.twig
  13. +1
    -1
      ShopBundle/Resources/views/backend/user/macros.html.twig

+ 32
- 0
ShopBundle/Event/EntityManager/EntityManagerEvent.php Voir le fichier

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

namespace Lc\ShopBundle\Event\EntityManager;

use Symfony\Contracts\EventDispatcher\Event;

/**
* class EntityEvent.
*
* @author Simon Vieille <simon@deblan.fr>
*/
class EntityManagerEvent extends Event
{
const CREATE_EVENT = 'entity_manager_event.create';
const UPDATE_EVENT = 'entity_manager_event.update';
const DELETE_EVENT = 'entity_manager_event.delete';
const PRE_CREATE_EVENT = 'entity_manager_event.pre_create';
const PRE_UPDATE_EVENT = 'entity_manager_event.pre_update';
const PRE_DELETE_EVENT = 'entity_manager_event.pre_delete';

protected $entity;

public function __construct($entity)
{
$this->entity = $entity;
}

public function getEntity()
{
return $this->entity;
}
}

+ 35
- 0
ShopBundle/Event/OrderShop/OrderShopChangeStatusEvent.php Voir le fichier

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

namespace Lc\ShopBundle\Event\OrderShop;

use Symfony\Contracts\EventDispatcher\Event;

/**
* class EntityEvent.
*
* @author Simon Vieille <simon@deblan.fr>
*/
class OrderShopChangeStatusEvent extends Event
{
const PRE_CHANGE_STATUS = 'order_shop_event.pre_change_status';
const POST_CHANGE_STATUS = 'order_shop_event.post_change_status';

protected $orderShop;
protected $orderStatus;

public function __construct($orderShop, $orderStatus)
{
$this->orderShop = $orderShop;
$this->orderStatus = $orderStatus;
}

public function getOrderShop()
{
return $this->orderShop;
}

public function getOrderStatus()
{
return $this->orderStatus;
}
}

+ 105
- 0
ShopBundle/Manager/EntityManager.php Voir le fichier

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

namespace Lc\ShopBundle\Manager;

use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\UserInterface;
use Lc\ShopBundle\Event\EntityManager\EntityManagerEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Security\Core\Security;

/**
* class EntityManager.
*
* @author Simon Vieille <simon@deblan.fr>
*/
class EntityManager
{
protected $eventDispatcher;
protected $entityManager;
protected $security;
protected $userSystem = null;

public function __construct(EventDispatcherInterface $eventDispatcher, EntityManagerInterface $entityManager,
Security $security)
{
$this->eventDispatcher = $eventDispatcher;
$this->entityManager = $entityManager;
$this->security = $security;
}


public function getUserSystem()
{
if ($this->userSystem === null) {
$this->userSystem = $this->getRepository(UserInterface::class)->findOneByDevAlias('system');
}
return $this->userSystem;
}

public function getRepository($className)
{
return $this->entityManager->getRepository($this->getEntityName($className));
}


public function create($entity): self
{

if ($this->security->getUser() === null) {
$entity->setUpdatedBy($this->getUserSystem());
$entity->setCreadtedBy($this->getUserSystem());
}
$this->persist($entity);
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::CREATE_EVENT);
return $this;
}

public function update($entity): self
{
if ($this->security->getUser() === null) {
$entity->setUpdatedBy($this->getUserSystem());
}
$this->persist($entity);
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::UPDATE_EVENT);

return $this;
}

public function delete($entity): self
{
$this->remove($entity);
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::DELETE_EVENT);

return $this;
}

public function flush(): self
{
$this->entityManager->flush();

return $this;
}

public function clear(): self
{
$this->entityManager->clear();

return $this;
}

protected function persist($entity)
{
$this->entityManager->persist($entity);
}

public function getEntityName($className)
{
if (substr($className, -9) === 'Interface') {
return $this->entityManager->getClassMetadata($className)->getName();
} else {
return $className;
}

}
}

+ 0
- 8
ShopBundle/Model/AbstractDocumentEntity.php Voir le fichier

@@ -38,17 +38,11 @@ abstract class AbstractDocumentEntity extends AbstractEntity implements StatusIn
*/
protected $description;



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





public function getTitle(): ?string
{
return $this->title;
@@ -74,8 +68,6 @@ abstract class AbstractDocumentEntity extends AbstractEntity implements StatusIn
return $this;
}



public function getDevAlias(): ?string
{
return $this->devAlias;

+ 1
- 1
ShopBundle/Model/OrderShop.php Voir le fichier

@@ -23,7 +23,7 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
protected $merchant;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="orders")
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="orders", fetch="EAGER")
*/
protected $user;


+ 0
- 1
ShopBundle/Model/User.php Voir le fichier

@@ -44,7 +44,6 @@ abstract class User extends UserModelFOS
*/
protected $orders;


/**
* @ORM\Column(type="string", length=64, nullable=true)
*/

+ 3
- 2
ShopBundle/Repository/BaseRepository.php Voir le fichier

@@ -66,11 +66,12 @@ class BaseRepository extends EntityRepository implements ServiceEntityRepository
return $qb->getQuery()->getOneOrNullResult();
}

public function findByMerchantQuery() :QueryBuilder
public function findByMerchantQuery($merchant = null) :QueryBuilder
{
if($merchant === false || $merchant===null)$merchant = $this->merchantUtils->getMerchantCurrent();
return $this->createQueryBuilder('e')
->where('e.merchant = :currentMerchant')
->setParameter('currentMerchant', $this->merchantUtils->getMerchantCurrent()->getId()) ;
->setParameter('currentMerchant', $merchant) ;
}

public function findAll()

+ 6
- 1
ShopBundle/Repository/OrderShopRepository.php Voir le fichier

@@ -119,7 +119,12 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt

public function findAllBy($params = [])
{
$query = $this->findByMerchantQuery();

if(isset($params['merchant'])){
$query = $this->findByMerchantQuery($params['merchant']);
}else{
$query = $this->findByMerchantQuery();
}

if (isset($params['count']) && $params['count']) {
$query->select('count(e.id)');

+ 3
- 2
ShopBundle/Repository/UserRepository.php Voir le fichier

@@ -19,12 +19,13 @@ class UserRepository extends BaseRepository implements DefaultRepositoryInterfac
return UserInterface::class;
}

public function findByMerchantQuery() :QueryBuilder
public function findByMerchantQuery($merchant = null) :QueryBuilder
{
if($merchant === false || $merchant===null)$merchant = $this->merchantUtils->getMerchantCurrent();
return $this->createQueryBuilder('e')
->innerJoin('e.userMerchants', "userMerchants")
->andWhere('userMerchants.merchant = :currentMerchant')
->setParameter('currentMerchant', $this->merchantUtils->getMerchantCurrent()->getId()) ;
->setParameter('currentMerchant', $merchant) ;
}

public function findAllByNewsletter($newsletter)

+ 21
- 18
ShopBundle/Resources/views/backend/default/block/macros.html.twig Voir le fichier

@@ -332,6 +332,7 @@


{% macro list_reduction_credits(reductionCredits, user) %}
{% set merchant_current = merchantUtils.getMerchantCurrent() %}
<table class="table table-condensed">
<thead>
<tr>
@@ -344,24 +345,26 @@
</thead>
<tbody>
{% for reductionCredit in reductionCredits %}
{% set isUsed = orderUtils.isReductionCreditUsed(reductionCredit, user) %}
<tr>
<td>{{ reductionCredit.title }}</td>
<td>
{{ reductionCredit.value|format_price(false) }}
</td>
<td>
{% include '@EasyAdmin/default/field_boolean.html.twig' with {value: reductionCredit.status} %}
</td>
<td>
{% include '@EasyAdmin/default/field_boolean.html.twig' with {value: isUsed} %}
</td>
<td>
{% if isUsed == false %}
{{ _self.button('ReductionCredit', 'edit', reductionCredit.id, 'primary') }}
{% endif %}
</td>
</tr>
{% if reductionCredit.getMerchant() == merchant_current %}
{% set isUsed = orderUtils.isReductionCreditUsed(reductionCredit, user) %}
<tr>
<td>{{ reductionCredit.title }}</td>
<td>
{{ reductionCredit.value|format_price(false) }}
</td>
<td>
{% include '@EasyAdmin/default/field_boolean.html.twig' with {value: reductionCredit.status} %}
</td>
<td>
{% include '@EasyAdmin/default/field_boolean.html.twig' with {value: isUsed} %}
</td>
<td>
{% if isUsed == false %}
{{ _self.button('ReductionCredit', 'edit', reductionCredit.id, 'primary') }}
{% endif %}
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>

+ 3
- 1
ShopBundle/Resources/views/backend/default/field/user.html.twig Voir le fichier

@@ -1,5 +1,7 @@
{% if item.user is not null %}
{% if item is defined and item.user is defined and item.user is not null %}
<a href="{{ path('easyadmin', {"entity": 'User', 'action': "show", "id" : item.user.id})}}">{{ value }}</a>
{% elseif user is defined and user is not null %}
<a href="{{ path('easyadmin', {"entity": 'User', 'action': "show", "id" : user.id})}}">{{ user }}</a>
{% else %}
{{ value }}
{% endif %}

+ 8
- 6
ShopBundle/Resources/views/backend/default/list.html.twig Voir le fichier

@@ -240,11 +240,11 @@
</th>
{% endfor %}

{% if _list_item_actions|length > 0 %}
{# {% if _list_item_actions|length > 0 %}#}
<th {% if _entity_config.list.collapse_actions %}width="10px"{% endif %} {{ easyadmin_config('design.rtl') ? 'dir="rtl"' }}>
<span class="sr-only">{{ 'list.row_actions'|trans(_trans_parameters, 'EasyAdminBundle') }}</span>
</th>
{% endif %}
{#{% endif %}#}
</tr>
{% endblock table_head %}
{% block table_filters %}
@@ -287,7 +287,7 @@

</th>
{% endfor %}
{% if _list_item_actions|length > 0 %}
{#{% if _list_item_actions|length > 0 %}#}
<th class="actions">
<button type="submit" form="filters-form" class="btn btn-sm btn-info"
data-toggle="tooltip"
@@ -307,7 +307,7 @@


</th>
{% endif %}
{# {% endif %}#}

</tr>
{% endif %}
@@ -353,9 +353,10 @@
</td>
{% endfor %}

<td class="actions">
{% if _list_item_actions|length > 0 %}
{% set _column_label = 'list.row_actions'|trans(_trans_parameters, 'EasyAdminBundle') %}
<td class="actions">
{% block item_actions %}
{% set _actions_template = '@LcShop/backend/default/block/actions.html.twig' %}
{{ include(_actions_template, {
@@ -368,8 +369,9 @@
item: item
}, with_context = false) }}
{% endblock item_actions %}
</td>
{% endif %}
</td>

</tr>
{% endif %}
{% else %}

+ 1
- 1
ShopBundle/Resources/views/backend/user/macros.html.twig Voir le fichier

@@ -37,7 +37,7 @@

<li class="list-group-item">
<b> <i class="fa fa-users"></i> Groupes</b>
{% for group in user.groups %}
{% for group in user.groupUsers %}
<span class="badge badge-info float-right">{{ group }}</span>&nbsp;
{% else %}
<span class="badge badge-dark float-right">Aucun</span>

Chargement…
Annuler
Enregistrer