Skip to content

Commit

Permalink
Update deprecated Security service in parseTemplate.md (#1443)
Browse files Browse the repository at this point in the history
Co-authored-by: Fritz Michael Gschwantner <[email protected]>
  • Loading branch information
CMSworker and fritzmg authored Oct 11, 2024
1 parent 7a6833a commit aa99922
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions docs/dev/reference/hooks/parseTemplate.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,14 @@ use Contao\CoreBundle\Security\ContaoCorePermissions;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
use Contao\FrontendTemplate;
use Contao\Template;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;

#[AsHook('parseTemplate')]
class ParseTemplateListener
{
private $security;

public function __construct(Security $security)
{
$this->security = $security;
public function __construct(
private readonly AuthorizationCheckerInterface $authorizationChecker
) {
}

public function __invoke(Template $template): void
Expand All @@ -72,7 +70,7 @@ class ParseTemplateListener
}

$template->isMemberOf = function ($groupId): bool {
return $this->security->isGranted(ContaoCorePermissions::MEMBER_IN_GROUPS, $groupId);
return $this->authorizationChecker->isGranted(ContaoCorePermissions::MEMBER_IN_GROUPS, $groupId);
};
}
}
Expand Down

0 comments on commit aa99922

Please sign in to comment.