namespace Lc\CaracoleBundle\Controller\User; | 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; | |||||
} | } |
use Doctrine\Common\Collections\Collection; | use Doctrine\Common\Collections\Collection; | ||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | ||||
use Lc\CaracoleBundle\Model\User\GroupUserInterface; | |||||
use Lc\SovBundle\Model\User\GroupUserInterface; | |||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
trait ReductionPropertyTrait | trait ReductionPropertyTrait | ||||
protected $users; | protected $users; | ||||
/** | /** | ||||
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\User\GroupUserInterface") | |||||
* @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\User\GroupUserInterface") | |||||
*/ | */ | ||||
protected $groupUsers; | protected $groupUsers; | ||||
public function setUserRolesFromKernelRequest(RequestEvent $event) | public function setUserRolesFromKernelRequest(RequestEvent $event) | ||||
{ | { | ||||
if (!$event->isMasterRequest()) { | |||||
if (!$event->isMainRequest()) { | |||||
return; | return; | ||||
} | } | ||||
if ($this->setUserRoles($event->getRequest())) { | if ($this->setUserRoles($event->getRequest())) { | ||||
} | } | ||||
} | } | ||||
return false; | |||||
} | } | ||||
return false; | |||||
} | } | ||||
namespace Lc\CaracoleBundle\Form\User; | namespace Lc\CaracoleBundle\Form\User; | ||||
use Lc\CaracoleBundle\Model\User\UserMerchantInterface; | use Lc\CaracoleBundle\Model\User\UserMerchantInterface; | ||||
use Lc\SovBundle\Definition\RolesDefinition; | |||||
use Lc\SovBundle\Definition\RolesDefinitionInterface; | use Lc\SovBundle\Definition\RolesDefinitionInterface; | ||||
use Lc\SovBundle\Doctrine\EntityManager; | use Lc\SovBundle\Doctrine\EntityManager; | ||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; |
use Lc\CaracoleBundle\Model\Setting\MerchantSettingInterface; | use Lc\CaracoleBundle\Model\Setting\MerchantSettingInterface; | ||||
use Lc\CaracoleBundle\Model\Site\NewsInterface; | use Lc\CaracoleBundle\Model\Site\NewsInterface; | ||||
use Lc\CaracoleBundle\Model\Site\PageInterface; | use Lc\CaracoleBundle\Model\Site\PageInterface; | ||||
use Lc\CaracoleBundle\Model\User\GroupUserInterface; | |||||
use Lc\SovBundle\Model\User\GroupUserInterface; | |||||
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | ||||
/** | /** | ||||
protected $newsletters; | protected $newsletters; | ||||
/** | /** | ||||
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\User\GroupUserInterface", mappedBy="merchant") | |||||
* @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\User\GroupUserInterface", mappedBy="merchant") | |||||
*/ | */ | ||||
protected $groupUsers; | protected $groupUsers; | ||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\SovBundle\Doctrine\EntityInterface; | use Lc\SovBundle\Doctrine\EntityInterface; | ||||
class MerchantSettingModel implements SettingInterface, EntityInterface | |||||
abstract class MerchantSettingModel implements SettingInterface, EntityInterface | |||||
{ | { | ||||
use SettingTrait; | 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) | * @ORM\JoinColumn(nullable=false) | ||||
*/ | */ | ||||
protected $merchant; | protected $merchant; |
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\SovBundle\Doctrine\EntityInterface; | use Lc\SovBundle\Doctrine\EntityInterface; | ||||
class SectionSettingModel implements SettingInterface, EntityInterface | |||||
abstract class SectionSettingModel implements SettingInterface, EntityInterface | |||||
{ | { | ||||
use SettingTrait; | 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) | * @ORM\JoinColumn(nullable=false) | ||||
*/ | */ | ||||
protected $section; | protected $section; |
<?php | |||||
namespace Lc\CaracoleBundle\Model\User; | |||||
interface GroupUserInterface | |||||
{ | |||||
} |
namespace Lc\CaracoleBundle\Model\User; | namespace Lc\CaracoleBundle\Model\User; | ||||
use Doctrine\ORM\Mapping as ORM; | 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\Doctrine\Extension\FilterMerchantInterface; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | 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() | * @ORM\MappedSuperclass() | ||||
*/ | */ | ||||
abstract class GroupUserModel extends AbstractFullEntity implements FilterMerchantInterface | |||||
abstract class GroupUserModel extends SovGroupUserModel implements FilterMerchantInterface | |||||
{ | { | ||||
/** | /** | ||||
*/ | */ | ||||
protected $merchant; | 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; | return $this->merchant; | ||||
} | } | ||||
public function setMerchant(?MerchantInterface $merchant): self | |||||
public function setMerchant(MerchantInterface $merchant): self | |||||
{ | { | ||||
$this->merchant = $merchant; | $this->merchant = $merchant; | ||||
return $this; | 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; | |||||
} | |||||
} | } |
*/ | */ | ||||
protected $newsletters; | protected $newsletters; | ||||
/** | |||||
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\User\GroupUserInterface", inversedBy="users") | |||||
*/ | |||||
protected $groupUsers; | |||||
/** | /** | ||||
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface") | * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface") | ||||
return $this; | 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[] | * @return Collection|ProductFamilyInterface[] |
namespace Lc\CaracoleBundle\Repository\User; | 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) | * @method GroupUserInterface|null find($id, $lockMode = null, $lockVersion = null) | ||||
* @method GroupUserInterface[] findAll() | * @method GroupUserInterface[] findAll() | ||||
* @method GroupUserInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | * @method GroupUserInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||||
*/ | */ | ||||
class GroupUserRepository extends AbstractRepository | |||||
class GroupUserRepository extends SovGroupUserRepository | |||||
{ | { | ||||
public function getInterfaceClass() | public function getInterfaceClass() | ||||
{ | { | ||||
return GroupUserInterface::class; | return GroupUserInterface::class; | ||||
} | } | ||||
} | } |
protected $em; | protected $em; | ||||
protected $urlResolver; | protected $urlResolver; | ||||
protected $security; | protected $security; | ||||
protected $currentMerchant; | |||||
public function __construct( | public function __construct( | ||||
EntityManagerInterface $entityManager, | EntityManagerInterface $entityManager, | ||||
public function getCurrent(): MerchantInterface | public function getCurrent(): MerchantInterface | ||||
{ | { | ||||
/* if($currentMerchant) { | |||||
return $currentMerchant ; | |||||
}*/ | |||||
if ($this->currentMerchant) { | |||||
return $this->currentMerchant; | |||||
} | |||||
$currentMerchant = false; | |||||
$this->currentMerchant = false; | |||||
$request = $this->requestStack->getCurrentRequest(); | $request = $this->requestStack->getCurrentRequest(); | ||||
$merchantRepository = $this->em->getRepository(MerchantInterface::class); | $merchantRepository = $this->em->getRepository(MerchantInterface::class); | ||||
$merchants = $merchantRepository->findAll(); | $merchants = $merchantRepository->findAll(); | ||||
if ($this->urlResolver->isServerLocalhost()) { | if ($this->urlResolver->isServerLocalhost()) { | ||||
foreach ($merchants as $merchant) { | foreach ($merchants as $merchant) { | ||||
if ($merchant->getId() == $_ENV['CURRENT_MERCHANT_LOCAL']) { | if ($merchant->getId() == $_ENV['CURRENT_MERCHANT_LOCAL']) { | ||||
$currentMerchant = $merchant; | |||||
$this->currentMerchant = $merchant; | |||||
} | } | ||||
} | } | ||||
} // distant | } // distant | ||||
foreach ($merchants as $merchant) { | foreach ($merchants as $merchant) { | ||||
$url = $merchant->getMerchantConfig('url'); | $url = $merchant->getMerchantConfig('url'); | ||||
if ($url && strlen($url) && strpos($url, $_SERVER['HTTP_HOST']) !== false) { | if ($url && strlen($url) && strpos($url, $_SERVER['HTTP_HOST']) !== false) { | ||||
$currentMerchant = $merchant; | |||||
$this->currentMerchant = $merchant; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
}*/ | }*/ | ||||
} | } | ||||
if ($currentMerchant instanceof MerchantInterface) { | |||||
return $currentMerchant; | |||||
if ($this->currentMerchant instanceof MerchantInterface) { | |||||
return $this->currentMerchant; | |||||
} else { | } else { | ||||
throw new \ErrorException('Aucun merchant courant'); | throw new \ErrorException('Aucun merchant courant'); | ||||
} | } | ||||
UserInterface $user = null, | UserInterface $user = null, | ||||
MerchantInterface $merchant = null | MerchantInterface $merchant = null | ||||
): ?UserMerchantInterface { | ): ?UserMerchantInterface { | ||||
$userMerchantRepository = $this->em->getRepository(UserMerchantInterface::class); | $userMerchantRepository = $this->em->getRepository(UserMerchantInterface::class); | ||||
if ($user === null) { | if ($user === null) { |
admin_section: Sections | admin_section: Sections | ||||
admin_tva: TVA | admin_tva: TVA | ||||
user_merchant_index: Utilisateurs | user_merchant_index: Utilisateurs | ||||
group_user_index: Groupes d'utilisateurs | |||||
flash_message: | flash_message: | ||||
settings_saved: Paramètres mis à jour | settings_saved: Paramètres mis à jour | ||||
lastname: Nom | lastname: Nom | ||||
firstname: Prénom | firstname: Prénom | ||||
creditActive: Crédit activer | creditActive: Crédit activer | ||||
GroupUser: | |||||
label: Groupe d'utilisateur | |||||
label_plurial: Groupes d'utilisateurs | |||||
form: | form: | ||||
user_merchant: | user_merchant: |