mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-27 17:15:02 +00:00
Inject services, no longer available in container by default
This commit is contained in:
@@ -27,6 +27,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
|
use Symfony\Contracts\Service\Attribute\Required;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,7 +63,46 @@ class CRUDController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
protected array $crudConfig;
|
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
|
public function CRUD(?string $parameter): Response
|
||||||
{
|
{
|
||||||
@@ -155,7 +195,7 @@ class CRUDController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
protected function buildDefaultRole($action)
|
protected function buildDefaultRole($action)
|
||||||
{
|
{
|
||||||
return $this->getCrudResolver()->buildDefaultRole(
|
return $this->resolver->buildDefaultRole(
|
||||||
$this->getCrudName(),
|
$this->getCrudName(),
|
||||||
$action
|
$action
|
||||||
);
|
);
|
||||||
@@ -595,10 +635,10 @@ class CRUDController extends AbstractController
|
|||||||
return $this->crudConfig['actions'][$action];
|
return $this->crudConfig['actions'][$action];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getAuthorizationHelper(): AuthorizationHelper
|
/* protected function getAuthorizationHelper(): AuthorizationHelper
|
||||||
{
|
{
|
||||||
return $this->container->get(AuthorizationHelper::class);
|
return $this->container->get(AuthorizationHelper::class);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string the crud name
|
* @return string the crud name
|
||||||
@@ -608,10 +648,10 @@ class CRUDController extends AbstractController
|
|||||||
return $this->crudConfig['name'];
|
return $this->crudConfig['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getCrudResolver(): Resolver
|
/* protected function getCrudResolver(): Resolver
|
||||||
{
|
{
|
||||||
return $this->get(Resolver::class);
|
return $this->get(Resolver::class);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
protected function getDefaultDeleteFormClass($action)
|
protected function getDefaultDeleteFormClass($action)
|
||||||
{
|
{
|
||||||
@@ -638,15 +678,15 @@ class CRUDController extends AbstractController
|
|||||||
return $this->crudConfig['class'];
|
return $this->crudConfig['class'];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getEventDispatcher(): EventDispatcherInterface
|
/* protected function getEventDispatcher(): EventDispatcherInterface
|
||||||
{
|
{
|
||||||
return $this->get(EventDispatcherInterface::class);
|
return $this->get(EventDispatcherInterface::class);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
protected function getFilterOrderHelperFactory(): FilterOrderHelperFactoryInterface
|
/* protected function getFilterOrderHelperFactory(): FilterOrderHelperFactoryInterface
|
||||||
{
|
{
|
||||||
return $this->get(FilterOrderHelperFactoryInterface::class);
|
return $this->get(FilterOrderHelperFactoryInterface::class);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the default form class from config.
|
* get the default form class from config.
|
||||||
@@ -694,7 +734,7 @@ class CRUDController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
protected function getReachableCenters(string $role, ?Scope $scope = null): array
|
protected function getReachableCenters(string $role, ?Scope $scope = null): array
|
||||||
{
|
{
|
||||||
return $this->getAuthorizationHelper()
|
return $this->authorizationHelper
|
||||||
->getReachableCenters($this->getUser(), $role, $scope);
|
->getReachableCenters($this->getUser(), $role, $scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -50,7 +50,6 @@ class UserController extends CRUDController
|
|||||||
protected ParameterBagInterface $parameterBag,
|
protected ParameterBagInterface $parameterBag,
|
||||||
private readonly TranslatorInterface $translator,
|
private readonly TranslatorInterface $translator,
|
||||||
private readonly ChillSecurity $security,
|
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')]
|
#[\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
|
protected function buildFilterOrderHelper(string $action, Request $request): ?FilterOrderHelper
|
||||||
{
|
{
|
||||||
return $this->getFilterOrderHelperFactory()
|
return $this->filterOrderHelperFactory
|
||||||
->create(self::class)
|
->create(self::class)
|
||||||
->addSearchBox(['label'])
|
->addSearchBox(['label'])
|
||||||
->addCheckbox('activeFilter', [true => 'Active', false => 'Inactive'], ['Active'])
|
->addCheckbox('activeFilter', [true => 'Active', false => 'Inactive'], ['Active'])
|
||||||
|
@@ -21,7 +21,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
*/
|
*/
|
||||||
class ClosingMotiveController extends CRUDController
|
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
|
* @param string $action
|
||||||
|
@@ -51,7 +51,7 @@ final class ThirdPartyController extends CRUDController
|
|||||||
|
|
||||||
protected function buildFilterOrderHelper(string $action, Request $request): ?FilterOrderHelper
|
protected function buildFilterOrderHelper(string $action, Request $request): ?FilterOrderHelper
|
||||||
{
|
{
|
||||||
return $this->getFilterOrderHelperFactory()
|
return $this->filterOrderHelperFactory
|
||||||
->create(self::class)
|
->create(self::class)
|
||||||
->addSearchBox(['name', 'company_name', 'acronym'])
|
->addSearchBox(['name', 'company_name', 'acronym'])
|
||||||
// ->addToggle('only-active', [])
|
// ->addToggle('only-active', [])
|
||||||
|
Reference in New Issue
Block a user