mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Inject services, no longer available in container by default
This commit is contained in:
parent
23227add12
commit
36fd6f10b2
@ -27,6 +27,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Contracts\Service\Attribute\Required;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
@ -62,7 +63,46 @@ class CRUDController extends AbstractController
|
||||
*/
|
||||
protected array $crudConfig;
|
||||
|
||||
public function __construct(private readonly ManagerRegistry $managerRegistry) {}
|
||||
protected Resolver $resolver;
|
||||
protected AuthorizationHelper $authorizationHelper;
|
||||
|
||||
protected EventDispatcherInterface $eventDispatcher;
|
||||
|
||||
protected FilterOrderHelperFactoryInterface $filterOrderHelperFactory;
|
||||
|
||||
protected ManagerRegistry $managerRegistry;
|
||||
|
||||
#[Required]
|
||||
public function setAuthorizationHelper(AuthorizationHelper $authorizationHelper): void
|
||||
{
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
}
|
||||
|
||||
#[Required]
|
||||
public function setResolver(Resolver $resolver): void
|
||||
{
|
||||
$this->resolver = $resolver;
|
||||
}
|
||||
|
||||
#[Required]
|
||||
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher): void
|
||||
{
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
#[Required]
|
||||
public function setFilterOrderHelperFactory(FilterOrderHelperFactoryInterface $filterOrderHelperFactory): void
|
||||
{
|
||||
$this->filterOrderHelperFactory = $filterOrderHelperFactory;
|
||||
}
|
||||
|
||||
#[Required]
|
||||
public function setManagerRegistry(ManagerRegistry $managerRegistry): void
|
||||
{
|
||||
$this->managerRegistry = $managerRegistry;
|
||||
}
|
||||
|
||||
// public function __construct(private readonly ManagerRegistry $managerRegistry) {}
|
||||
|
||||
public function CRUD(?string $parameter): Response
|
||||
{
|
||||
@ -155,7 +195,7 @@ class CRUDController extends AbstractController
|
||||
*/
|
||||
protected function buildDefaultRole($action)
|
||||
{
|
||||
return $this->getCrudResolver()->buildDefaultRole(
|
||||
return $this->resolver->buildDefaultRole(
|
||||
$this->getCrudName(),
|
||||
$action
|
||||
);
|
||||
@ -595,10 +635,10 @@ class CRUDController extends AbstractController
|
||||
return $this->crudConfig['actions'][$action];
|
||||
}
|
||||
|
||||
protected function getAuthorizationHelper(): AuthorizationHelper
|
||||
/* protected function getAuthorizationHelper(): AuthorizationHelper
|
||||
{
|
||||
return $this->container->get(AuthorizationHelper::class);
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* @return string the crud name
|
||||
@ -608,10 +648,10 @@ class CRUDController extends AbstractController
|
||||
return $this->crudConfig['name'];
|
||||
}
|
||||
|
||||
protected function getCrudResolver(): Resolver
|
||||
/* protected function getCrudResolver(): Resolver
|
||||
{
|
||||
return $this->get(Resolver::class);
|
||||
}
|
||||
}*/
|
||||
|
||||
protected function getDefaultDeleteFormClass($action)
|
||||
{
|
||||
@ -638,15 +678,15 @@ class CRUDController extends AbstractController
|
||||
return $this->crudConfig['class'];
|
||||
}
|
||||
|
||||
protected function getEventDispatcher(): EventDispatcherInterface
|
||||
/* protected function getEventDispatcher(): EventDispatcherInterface
|
||||
{
|
||||
return $this->get(EventDispatcherInterface::class);
|
||||
}
|
||||
}*/
|
||||
|
||||
protected function getFilterOrderHelperFactory(): FilterOrderHelperFactoryInterface
|
||||
/* protected function getFilterOrderHelperFactory(): FilterOrderHelperFactoryInterface
|
||||
{
|
||||
return $this->get(FilterOrderHelperFactoryInterface::class);
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* get the default form class from config.
|
||||
@ -694,7 +734,7 @@ class CRUDController extends AbstractController
|
||||
*/
|
||||
protected function getReachableCenters(string $role, ?Scope $scope = null): array
|
||||
{
|
||||
return $this->getAuthorizationHelper()
|
||||
return $this->authorizationHelper
|
||||
->getReachableCenters($this->getUser(), $role, $scope);
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,6 @@ class UserController extends CRUDController
|
||||
protected ParameterBagInterface $parameterBag,
|
||||
private readonly TranslatorInterface $translator,
|
||||
private readonly ChillSecurity $security,
|
||||
private readonly ManagerRegistry $managerRegistry,
|
||||
) {}
|
||||
|
||||
#[\Symfony\Component\Routing\Attribute\Route(path: '/{_locale}/admin/main/user/{uid}/add_link_groupcenter', name: 'admin_user_add_groupcenter')]
|
||||
@ -269,7 +268,7 @@ class UserController extends CRUDController
|
||||
|
||||
protected function buildFilterOrderHelper(string $action, Request $request): ?FilterOrderHelper
|
||||
{
|
||||
return $this->getFilterOrderHelperFactory()
|
||||
return $this->filterOrderHelperFactory
|
||||
->create(self::class)
|
||||
->addSearchBox(['label'])
|
||||
->addCheckbox('activeFilter', [true => 'Active', false => 'Inactive'], ['Active'])
|
||||
|
@ -21,7 +21,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
*/
|
||||
class ClosingMotiveController extends CRUDController
|
||||
{
|
||||
public function __construct(private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
// public function __construct(private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
|
||||
/**
|
||||
* @param string $action
|
||||
|
@ -51,7 +51,7 @@ final class ThirdPartyController extends CRUDController
|
||||
|
||||
protected function buildFilterOrderHelper(string $action, Request $request): ?FilterOrderHelper
|
||||
{
|
||||
return $this->getFilterOrderHelperFactory()
|
||||
return $this->filterOrderHelperFactory
|
||||
->create(self::class)
|
||||
->addSearchBox(['name', 'company_name', 'acronym'])
|
||||
// ->addToggle('only-active', [])
|
||||
|
Loading…
x
Reference in New Issue
Block a user