Browse Source

RoleDefinitionInterface

feature/symfony6.1
Charly 3 years ago
parent
commit
9d62653d9c
2 changed files with 16 additions and 15 deletions
  1. +15
    -6
      Container/User/UserContainer.php
  2. +1
    -9
      Controller/User/UserAdminController.php

+ 15
- 6
Container/User/UserContainer.php View File



use Lc\SovBundle\Builder\User\UserBuilder; use Lc\SovBundle\Builder\User\UserBuilder;
use Lc\SovBundle\Definition\Field\User\UserFieldDefinition; use Lc\SovBundle\Definition\Field\User\UserFieldDefinition;
use Lc\SovBundle\Definition\RolesDefinitionInterface;
use Lc\SovBundle\Factory\User\UserFactory; use Lc\SovBundle\Factory\User\UserFactory;
use Lc\SovBundle\Repository\User\UserRepositoryQuery; use Lc\SovBundle\Repository\User\UserRepositoryQuery;
use Lc\SovBundle\Repository\User\UserStore; use Lc\SovBundle\Repository\User\UserStore;
protected UserStore $store; protected UserStore $store;
protected UserSolver $solver; protected UserSolver $solver;
protected UserFieldDefinition $fieldDefinition; protected UserFieldDefinition $fieldDefinition;
protected RolesDefinitionInterface $rolesDefinition;


public function __construct( public function __construct(
UserFactory $factory,
UserBuilder $builder,
UserRepositoryQuery $repositoryQuery,
UserStore $store,
UserSolver $solver,
UserFieldDefinition $fieldDefinition
UserFactory $factory,
UserBuilder $builder,
UserRepositoryQuery $repositoryQuery,
UserStore $store,
UserSolver $solver,
UserFieldDefinition $fieldDefinition,
RolesDefinitionInterface $rolesDefinition
) { ) {
$this->factory = $factory; $this->factory = $factory;
$this->builder = $builder; $this->builder = $builder;
$this->store = $store; $this->store = $store;
$this->solver = $solver; $this->solver = $solver;
$this->fieldDefinition = $fieldDefinition; $this->fieldDefinition = $fieldDefinition;
$this->rolesDefinition = $rolesDefinition;
} }


public function getFactory(): UserFactory public function getFactory(): UserFactory
{ {
return $this->fieldDefinition; return $this->fieldDefinition;
} }

public function getRoleDefinition(): RolesDefinitionInterface
{
return $this->rolesDefinition;
}
} }

+ 1
- 9
Controller/User/UserAdminController.php View File



abstract class UserAdminController extends AbstractAdminController abstract class UserAdminController extends AbstractAdminController
{ {
protected RolesDefinitionInterface $rolesDefinition;

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

public function buildIndexActions(Actions $actions): void public function buildIndexActions(Actions $actions): void
{ {
parent::buildIndexActions($actions); // TODO: Change the autogenerated stub parent::buildIndexActions($actions); // TODO: Change the autogenerated stub
ChoiceField::new('roles') ChoiceField::new('roles')
->allowMultipleChoices() ->allowMultipleChoices()
->autocomplete() ->autocomplete()
->setChoices($this->rolesDefinition->getRolesList())
->setChoices($this->getUserContainer()->getRoleDefinition()->getRolesList())
]; ];
} }



Loading…
Cancel
Save