Skip to content

Commit

Permalink
Merge pull request #13 from 2lenet/improvement/cache-sf6
Browse files Browse the repository at this point in the history
SF6 Compatibility
  • Loading branch information
sebheitzmann authored Nov 2, 2022
2 parents 3da6875 + ca57222 commit 839c0ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
22 changes: 11 additions & 11 deletions src/Controller/CredentialManagerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
use Lle\CredentialBundle\Entity\Group;
use Lle\CredentialBundle\Entity\GroupRepository;
use Lle\CredentialBundle\Entity\GroupCredential;
use Psr\Cache\CacheItemPoolInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\Cache\Adapter\AdapterInterface;

use Symfony\Component\Routing\Annotation\Route;

Expand Down Expand Up @@ -65,7 +65,7 @@ public function index()
* @Route("/admin/credential/toggle", name="admin_credential_toggle")
* @Security("is_granted('ROLE_ADMIN_DROITS')")
*/
public function toggle(Request $request, AdapterInterface $cache)
public function toggle(Request $request, CacheItemPoolInterface $cache): JsonResponse
{
$cache->deleteItem('group_credentials');
$var = $request->request->get('id');
Expand All @@ -76,12 +76,12 @@ public function toggle(Request $request, AdapterInterface $cache)
$groupObj = $this->em->getRepository(Group::class)->findOneByName($group);
$credential = $this->em->getRepository(Credential::class)->findOneByRole($cred);

$group_cred = new GroupCredential();
$group_cred = new GroupCredential();
$group_cred->setGroupe($groupObj);
$group_cred->setCredential($credential);
$group_cred->setAllowed(true);
} else {
$group_cred->setAllowed(! $group_cred->isAllowed());
$group_cred->setAllowed(!$group_cred->isAllowed());
}

$this->em->persist($group_cred);
Expand All @@ -94,7 +94,7 @@ public function toggle(Request $request, AdapterInterface $cache)
* @Route("/admin/credential/toggle_all", name="admin_credential_toggle_all")
* @Security("is_granted('ROLE_ADMIN_DROITS')")
*/
public function toggleAll(Request $request, AdapterInterface $cache)
public function toggleAll(Request $request, CacheItemPoolInterface $cache): JsonResponse
{
$cache->deleteItem('group_credentials');
$group = $request->request->getInt('group');
Expand Down Expand Up @@ -125,7 +125,7 @@ public function toggleAll(Request $request, AdapterInterface $cache)
/** @var Credential $credential */
foreach ($credentials as $credential) {
if (!array_key_exists($credential->getId(), $existingCredentials)) {
$groupCredential = new GroupCredential();
$groupCredential = new GroupCredential();
$groupCredential->setGroupe($group);
$groupCredential->setCredential($credential);
$groupCredential->setAllowed($checked);
Expand All @@ -145,7 +145,7 @@ public function toggleAll(Request $request, AdapterInterface $cache)
* @Route("/admin/credential/allowed_status", name="admin_credential_allowed_status")
* @Security("is_granted('ROLE_ADMIN_DROITS')")
*/
public function allowedStatus(Request $request, AdapterInterface $cache)
public function allowedStatus(Request $request, CacheItemPoolInterface $cache): JsonResponse
{
$cache->deleteItem("group_credentials");

Expand All @@ -158,13 +158,13 @@ public function allowedStatus(Request $request, AdapterInterface $cache)
$groupObj = $this->em->getRepository(Group::class)->findOneByName($group);
$credential = $this->em->getRepository(Credential::class)->findOneByRole($cred);

$groupCred = new GroupCredential();
$groupCred = new GroupCredential();
$groupCred->setGroupe($groupObj);
$groupCred->setCredential($credential);
$groupCred->setAllowed(false);
$groupCred->setStatusAllowed(true);
} else {
$groupCred->setStatusAllowed(! $groupCred->isStatusAllowed());
$groupCred->setStatusAllowed(!$groupCred->isStatusAllowed());
}

$this->em->persist($groupCred);
Expand All @@ -177,7 +177,7 @@ public function allowedStatus(Request $request, AdapterInterface $cache)
* @Route("/admin/credential/allowed_for_status", name="admin_credential_allowed_for_status")
* @Security("is_granted('ROLE_ADMIN_DROITS')")
*/
public function allowedByStatus(Request $request, AdapterInterface $cache)
public function allowedByStatus(Request $request, CacheItemPoolInterface $cache): JsonResponse
{
$cache->deleteItem("group_credentials");

Expand Down Expand Up @@ -209,7 +209,7 @@ public function allowedByStatus(Request $request, AdapterInterface $cache)
$groupCred->setCredential($credential);
$groupCred->setAllowed(true);
} else {
$groupCred->setAllowed(! $groupCred->isAllowed());
$groupCred->setAllowed(!$groupCred->isAllowed());
}

$this->em->persist($groupCred);
Expand Down
3 changes: 0 additions & 3 deletions src/Security/CredentialVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

namespace Lle\CredentialBundle\Security;

use Lle\CredentialBundle\Model\StatusPropertyInterface;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\ORM\EntityManagerInterface;
use Lle\CredentialBundle\Entity\Credential;
use Lle\CredentialBundle\Entity\Group;
use Lle\CredentialBundle\Entity\GroupCredential;
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Psr\Cache\CacheItemPoolInterface;

Expand Down

0 comments on commit 839c0ee

Please sign in to comment.