Ver código fonte

Déplacement GroupUser Caracole -> Sov

feature/ticket
Fab 3 anos atrás
pai
commit
67affcbb73
13 arquivos alterados com 36 adições e 118 exclusões
  1. +5
    -2
      Controller/User/GroupUserAdminController.php
  2. +2
    -2
      Doctrine/Extension/ReductionPropertyTrait.php
  3. +2
    -2
      EventSubscriber/User/UserRolesEventSubscriber.php
  4. +0
    -1
      Form/User/UserMerchantFormType.php
  5. +2
    -2
      Model/Merchant/MerchantModel.php
  6. +2
    -2
      Model/Setting/MerchantSettingModel.php
  7. +2
    -2
      Model/Setting/SectionSettingModel.php
  8. +0
    -8
      Model/User/GroupUserInterface.php
  9. +4
    -52
      Model/User/GroupUserModel.php
  10. +1
    -31
      Model/User/UserModel.php
  11. +3
    -5
      Repository/User/GroupUserRepository.php
  12. +9
    -9
      Resolver/MerchantResolver.php
  13. +4
    -0
      Resources/translations/admin.fr.yaml

+ 5
- 2
Controller/User/GroupUserAdminController.php Ver arquivo

@@ -2,9 +2,12 @@

namespace Lc\CaracoleBundle\Controller\User;

use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\SovBundle\Controller\User\GroupUserAdminController as SovGroupUserAdminController;

abstract class GroupUserAdminController extends AbstractAdminController
abstract class GroupUserAdminController extends SovGroupUserAdminController
{

use AdminControllerTrait;

}

+ 2
- 2
Doctrine/Extension/ReductionPropertyTrait.php Ver arquivo

@@ -6,7 +6,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\User\GroupUserInterface;
use Lc\SovBundle\Model\User\GroupUserInterface;
use Lc\SovBundle\Model\User\UserInterface;

trait ReductionPropertyTrait
@@ -18,7 +18,7 @@ trait ReductionPropertyTrait
protected $users;

/**
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\User\GroupUserInterface")
* @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\User\GroupUserInterface")
*/
protected $groupUsers;


+ 2
- 2
EventSubscriber/User/UserRolesEventSubscriber.php Ver arquivo

@@ -46,7 +46,7 @@ class UserRolesEventSubscriber implements EventSubscriberInterface

public function setUserRolesFromKernelRequest(RequestEvent $event)
{
if (!$event->isMasterRequest()) {
if (!$event->isMainRequest()) {
return;
}
if ($this->setUserRoles($event->getRequest())) {
@@ -93,8 +93,8 @@ class UserRolesEventSubscriber implements EventSubscriberInterface
}
}

return false;
}
return false;
}



+ 0
- 1
Form/User/UserMerchantFormType.php Ver arquivo

@@ -3,7 +3,6 @@
namespace Lc\CaracoleBundle\Form\User;

use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
use Lc\SovBundle\Definition\RolesDefinition;
use Lc\SovBundle\Definition\RolesDefinitionInterface;
use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Model\User\UserInterface;

+ 2
- 2
Model/Merchant/MerchantModel.php Ver arquivo

@@ -16,7 +16,7 @@ use Lc\CaracoleBundle\Model\Setting\EntitySettingTrait;
use Lc\CaracoleBundle\Model\Setting\MerchantSettingInterface;
use Lc\CaracoleBundle\Model\Site\NewsInterface;
use Lc\CaracoleBundle\Model\Site\PageInterface;
use Lc\CaracoleBundle\Model\User\GroupUserInterface;
use Lc\SovBundle\Model\User\GroupUserInterface;
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;

/**
@@ -76,7 +76,7 @@ abstract class MerchantModel extends AbstractFullEntity
protected $newsletters;

/**
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\User\GroupUserInterface", mappedBy="merchant")
* @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\User\GroupUserInterface", mappedBy="merchant")
*/
protected $groupUsers;


+ 2
- 2
Model/Setting/MerchantSettingModel.php Ver arquivo

@@ -6,12 +6,12 @@ use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Doctrine\ORM\Mapping as ORM;
use Lc\SovBundle\Doctrine\EntityInterface;

class MerchantSettingModel implements SettingInterface, EntityInterface
abstract class MerchantSettingModel implements SettingInterface, EntityInterface
{
use SettingTrait;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="merchantSettings")
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="settings")
* @ORM\JoinColumn(nullable=false)
*/
protected $merchant;

+ 2
- 2
Model/Setting/SectionSettingModel.php Ver arquivo

@@ -6,12 +6,12 @@ use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Doctrine\ORM\Mapping as ORM;
use Lc\SovBundle\Doctrine\EntityInterface;

class SectionSettingModel implements SettingInterface, EntityInterface
abstract class SectionSettingModel implements SettingInterface, EntityInterface
{
use SettingTrait;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="sectionSettings")
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="settings")
* @ORM\JoinColumn(nullable=false)
*/
protected $section;

+ 0
- 8
Model/User/GroupUserInterface.php Ver arquivo

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

namespace Lc\CaracoleBundle\Model\User;

interface GroupUserInterface
{

}

+ 4
- 52
Model/User/GroupUserModel.php Ver arquivo

@@ -3,18 +3,14 @@
namespace Lc\CaracoleBundle\Model\User;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
use Lc\SovBundle\Model\User\UserInterface;

use Lc\SovBundle\Model\User\GroupUserModel as SovGroupUserModel;

/**
* @ORM\MappedSuperclass()
*/
abstract class GroupUserModel extends AbstractFullEntity implements FilterMerchantInterface
abstract class GroupUserModel extends SovGroupUserModel implements FilterMerchantInterface
{

/**
@@ -23,60 +19,16 @@ abstract class GroupUserModel extends AbstractFullEntity implements FilterMercha
*/
protected $merchant;

/**
* @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\User\UserInterface", mappedBy="groupUsers")
*/
protected $users;


public function __toString()
{
return $this->getTitle();
}


public function __construct()
{
$this->users = new ArrayCollection();
}

public function getMerchant(): ?MerchantInterface
public function getMerchant(): MerchantInterface
{
return $this->merchant;
}

public function setMerchant(?MerchantInterface $merchant): self
public function setMerchant(MerchantInterface $merchant): self
{
$this->merchant = $merchant;

return $this;
}

public function addUser(UserModel $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
}

return $this;
}

/**
* @return Collection|UserInterface[]
*/
public function getUsers(): Collection
{
return $this->users;
}

public function removeUser(UserInterface $user): self
{
if ($this->users->contains($user)) {
$this->users->removeElement($user);
}

return $this;
}


}

+ 1
- 31
Model/User/UserModel.php Ver arquivo

@@ -67,10 +67,7 @@ abstract class UserModel extends SovUserModel
*/
protected $newsletters;

/**
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\User\GroupUserInterface", inversedBy="users")
*/
protected $groupUsers;


/**
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface")
@@ -303,33 +300,6 @@ abstract class UserModel extends SovUserModel
return $this;
}

/**
* @return Collection|GroupUserInterface[]
*/
public function getGroupUsers(): Collection
{
return $this->groupUsers;
}

public function addGroupUser(GroupUserInterface $groupUser): self
{
if (!$this->groupUsers->contains($groupUser)) {
$this->groupUsers[] = $groupUser;
$groupUser->addUser($this);
}

return $this;
}

public function removeGroupUser(GroupUserInterface $groupUser): self
{
if ($this->groupUsers->contains($groupUser)) {
$this->groupUsers->removeElement($groupUser);
$groupUser->removeUser($this);
}

return $this;
}

/**
* @return Collection|ProductFamilyInterface[]

+ 3
- 5
Repository/User/GroupUserRepository.php Ver arquivo

@@ -2,8 +2,8 @@

namespace Lc\CaracoleBundle\Repository\User;

use Lc\CaracoleBundle\Model\User\GroupUserInterface;
use Lc\SovBundle\Repository\AbstractRepository;
use Lc\SovBundle\Model\User\GroupUserInterface;
use Lc\SovBundle\Repository\User\GroupUserRepository as SovGroupUserRepository;

/**
* @method GroupUserInterface|null find($id, $lockMode = null, $lockVersion = null)
@@ -11,12 +11,10 @@ use Lc\SovBundle\Repository\AbstractRepository;
* @method GroupUserInterface[] findAll()
* @method GroupUserInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class GroupUserRepository extends AbstractRepository
class GroupUserRepository extends SovGroupUserRepository
{
public function getInterfaceClass()
{
return GroupUserInterface::class;
}


}

+ 9
- 9
Resolver/MerchantResolver.php Ver arquivo

@@ -22,6 +22,7 @@ class MerchantResolver
protected $em;
protected $urlResolver;
protected $security;
protected $currentMerchant;

public function __construct(
EntityManagerInterface $entityManager,
@@ -37,11 +38,11 @@ class MerchantResolver

public function getCurrent(): MerchantInterface
{
/* if($currentMerchant) {
return $currentMerchant ;
}*/
if ($this->currentMerchant) {
return $this->currentMerchant;
}

$currentMerchant = false;
$this->currentMerchant = false;
$request = $this->requestStack->getCurrentRequest();
$merchantRepository = $this->em->getRepository(MerchantInterface::class);
$merchants = $merchantRepository->findAll();
@@ -50,7 +51,7 @@ class MerchantResolver
if ($this->urlResolver->isServerLocalhost()) {
foreach ($merchants as $merchant) {
if ($merchant->getId() == $_ENV['CURRENT_MERCHANT_LOCAL']) {
$currentMerchant = $merchant;
$this->currentMerchant = $merchant;
}
}
} // distant
@@ -58,7 +59,7 @@ class MerchantResolver
foreach ($merchants as $merchant) {
$url = $merchant->getMerchantConfig('url');
if ($url && strlen($url) && strpos($url, $_SERVER['HTTP_HOST']) !== false) {
$currentMerchant = $merchant;
$this->currentMerchant = $merchant;
}
}
}
@@ -72,8 +73,8 @@ class MerchantResolver
}*/
}

if ($currentMerchant instanceof MerchantInterface) {
return $currentMerchant;
if ($this->currentMerchant instanceof MerchantInterface) {
return $this->currentMerchant;
} else {
throw new \ErrorException('Aucun merchant courant');
}
@@ -84,7 +85,6 @@ class MerchantResolver
UserInterface $user = null,
MerchantInterface $merchant = null
): ?UserMerchantInterface {

$userMerchantRepository = $this->em->getRepository(UserMerchantInterface::class);

if ($user === null) {

+ 4
- 0
Resources/translations/admin.fr.yaml Ver arquivo

@@ -8,6 +8,7 @@ menu:
admin_section: Sections
admin_tva: TVA
user_merchant_index: Utilisateurs
group_user_index: Groupes d'utilisateurs

flash_message:
settings_saved: Paramètres mis à jour
@@ -48,6 +49,9 @@ entity:
lastname: Nom
firstname: Prénom
creditActive: Crédit activer
GroupUser:
label: Groupe d'utilisateur
label_plurial: Groupes d'utilisateurs

form:
user_merchant:

Carregando…
Cancelar
Salvar