Pārlūkot izejas kodu

Implementation de user

packProduct
Fab pirms 3 gadiem
vecāks
revīzija
e21dbedc56
6 mainītis faili ar 166 papildinājumiem un 1 dzēšanām
  1. +76
    -0
      Controller/User/UserAdminController.php
  2. +69
    -0
      Definition/Field/User/UserFieldDefinition.php
  3. +1
    -0
      Repository/Newsletter/NewsletterRepositoryQuery.php
  4. +8
    -0
      Repository/Newsletter/NewsletterStore.php
  5. +4
    -0
      Resources/translations/admin.fr.yaml
  6. +8
    -1
      Solver/Address/AddressSolver.php

+ 76
- 0
Controller/User/UserAdminController.php Parādīt failu

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

namespace Lc\CaracoleBundle\Controller\User;

use App\Entity\Address;
use App\Form\Backend\Common\AddressType;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\Filters;
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter;
use Lc\CaracoleBundle\Container\Address\AddressContainer;
use Lc\CaracoleBundle\Controller\ControllerTrait;
use Lc\SovBundle\Container\User\UserContainer;
use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\HttpFoundation\Response;

abstract class UserAdminController extends AbstractAdminController
{
use ControllerTrait;

public function getRepositoryQuery(): RepositoryQueryInterface
{
return $this->getUserContainer()->getRepositoryQuery();
}

public function createEntity(string $entityFqcn)
{
return $this->getUserContainer()->getFactory()->create();
}

public function configureFields(string $pageName): iterable
{

$fields = $this->get(UserContainer::class)
->getFieldDefinition()
->setMerchant($this->getMerchantCurrent())
->getAllFields();

if($pageName == Crud::PAGE_INDEX){
return [
$fields['id'],
$fields['gender'],
$fields['lastname'],
$fields['firstname'],
$fields['email'],
$fields['phone'],
$fields['birthdate'],
$fields['groupUsers'],
$fields['isSaleAlwaysOpen'],
$fields['newsletters']
];
}elseif($pageName == Crud::PAGE_EDIT || $pageName == Crud::PAGE_NEW){
$fieldToReturn = [
$fields['id'],
$fields['gender'],
$fields['lastname'],
$fields['firstname'],
$fields['email'],
$fields['phone'],
$fields['birthdate'],
$fields['groupUsers'],
$fields['isSaleAlwaysOpen'],
$fields['newsletters']
];

if($this->isGranted('ROLE_SUPER_ADMIN')){
$fieldToReturn[] = $fields['roles'];
}
return $fieldToReturn;
}
}



}

+ 69
- 0
Definition/Field/User/UserFieldDefinition.php Parādīt failu

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

namespace Lc\CaracoleBundle\Definition\Field\User;

use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Field\AssociationField;
use Lc\CaracoleBundle\Repository\Newsletter\NewsletterStore;
use Lc\CaracoleBundle\Repository\User\GroupUserStore;
use Lc\SovBundle\Definition\Field\User\UserFieldDefinition as SovUserFieldDefinition;
use Lc\SovBundle\Definition\RolesDefinition;
use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Translation\TranslatorAdmin;

use function Clue\StreamFilter\fun;

class UserFieldDefinition extends SovUserFieldDefinition
{
use MerchantContextTrait;

protected GroupUserStore $groupUserStore;
protected NewsletterStore $newsletterStore;

public function __construct(TranslatorAdmin $translatorAdmin, RolesDefinition $rolesDefinition, GroupUserStore $groupUserStore, NewsletterStore $newsletterStore)
{
parent::__construct($translatorAdmin, $rolesDefinition);

$this->groupUserStore = $groupUserStore;
$this->newsletterStore = $newsletterStore;
}

public function configureForm(): array
{
return [
'gender',
'lastname',
'firstname',
'email',
'phone',
'birthdate',
'groupUsers',
'isSaleAlwaysOpen',
'newsletters'
];
}

public function configureFields(): array
{
$groupUsers = $this->groupUserStore->setMerchant($this->merchant)->getAll();
$newsletters = $this->newsletterStore->getAll();

return array_merge(parent::configureFields(),[
'isSaleAlwaysOpen' => BooleanField::new('isSaleAlwaysOpen'),
'newsletters' => AssociationField::new('newsletters')
->setFormTypeOption('choices', $newsletters)
->setFormTypeOption('choice_label', function ($choice) {
return $choice->getTitle(). '['.$choice->getSection()->getMerchant().']';
})
->setSortable(true),
'groupUsers' => AssociationField::new('groupUsers')
->setFormTypeOption('choices', $groupUsers)
->setFormTypeOption('choice_label', function ($choice) {
return $choice->getTitle(). '['.$choice->getMerchant().']';
})
->setSortable(true)

]);
}

}

+ 1
- 0
Repository/Newsletter/NewsletterRepositoryQuery.php Parādīt failu

@@ -2,6 +2,7 @@

namespace Lc\CaracoleBundle\Repository\Newsletter;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Repository\Newsletter\NewsletterRepositoryQuery as SovNewsletterRepositoryQuery;

+ 8
- 0
Repository/Newsletter/NewsletterStore.php Parādīt failu

@@ -2,6 +2,7 @@

namespace Lc\CaracoleBundle\Repository\Newsletter;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\Newsletter\NewsletterStore as SovNewsletterStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
@@ -27,4 +28,11 @@ class NewsletterStore extends SovNewsletterStore
{
return $query;
}

public function getByMerchant(MerchantInterface $merchant, RepositoryQueryInterface $query = null):array
{
$query = $this->createQuery($query);
$query->filterByMerchantViaSection($merchant);
return $query->find();
}
}

+ 4
- 0
Resources/translations/admin.fr.yaml Parādīt failu

@@ -118,6 +118,10 @@ entity:
lastname: Nom
firstname: Prénom
creditActive: Crédit activer
User:
fields:
isSaleAlwaysOpen: Vente toujours ouverte
newsletters: Newsletter
CreditHistory:
label: Historique de compte prépayé
label_plurial: Historiques de compte prépayé

+ 8
- 1
Solver/Address/AddressSolver.php Parādīt failu

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Solver\Address;

use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Address\AddressModel;

class AddressSolver
{
@@ -58,5 +59,11 @@ class AddressSolver
return $address->getLatitude();
}
}
public static function getTypeChoices():array{
return[
AddressModel::TYPE_INDIVIDUAL,
AddressModel::TYPE_LEGAL_PERSON,
];
}

}
}

Notiek ielāde…
Atcelt
Saglabāt