Skip to content

Commit a3bcfa2

Browse files
authored
Merge pull request #134 from Novactive/ezprotectedcontentbundle-fix-admin-modal
#106733 - novactive/ezprotectedcontentbundle - gestion de la protection par mot de passe d'un contenu
2 parents 026765a + 8ca3c7e commit a3bcfa2

2 files changed

Lines changed: 9 additions & 18 deletions

File tree

bundle/Controller/Admin/ProtectedAccessController.php

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use DateTime;
1818
use Doctrine\ORM\EntityManagerInterface;
1919
use eZ\Publish\API\Repository\Values\Content\Location;
20-
use EzSystems\PlatformHttpCacheBundle\PurgeClient\PurgeClientInterface;
20+
use Ibexa\Contracts\HttpCache\Handler\ContentTagInterface;
2121
use Novactive\Bundle\eZProtectedContentBundle\Entity\ProtectedAccess;
2222
use Novactive\Bundle\eZProtectedContentBundle\Form\ProtectedAccessType;
2323
use Symfony\Component\Form\FormFactoryInterface;
@@ -38,7 +38,7 @@ public function handle(
3838
FormFactoryInterface $formFactory,
3939
EntityManagerInterface $entityManager,
4040
RouterInterface $router,
41-
PurgeClientInterface $httpCachePurgeClient,
41+
ContentTagInterface $responseTagger,
4242
?ProtectedAccess $access = null
4343
): RedirectResponse {
4444
if ($request->isMethod('post')) {
@@ -54,12 +54,8 @@ public function handle(
5454
$access->setUpdated($now);
5555
$entityManager->persist($access);
5656
$entityManager->flush();
57-
$httpCachePurgeClient->purge(
58-
[
59-
'location-'.$location->id,
60-
'location-'.$location->parentLocationId,
61-
]
62-
);
57+
$responseTagger->addLocationTags([$location->id]);
58+
$responseTagger->addParentLocationTags([$location->parentLocationId]);
6359
}
6460
}
6561

@@ -78,18 +74,14 @@ public function remove(
7874
Location $location,
7975
EntityManagerInterface $entityManager,
8076
RouterInterface $router,
81-
ProtectedAccess $access,
82-
PurgeClientInterface $httpCachePurgeClient
77+
int $access,
78+
ContentTagInterface $responseTagger
8379
): RedirectResponse {
80+
$access = $entityManager->find(ProtectedAccess::class, $access);
8481
$entityManager->remove($access);
8582
$entityManager->flush();
86-
87-
$httpCachePurgeClient->purge(
88-
[
89-
'location-'.$location->id,
90-
'location-'.$location->parentLocationId,
91-
]
92-
);
83+
$responseTagger->addLocationTags([$location->id]);
84+
$responseTagger->addParentLocationTags([$location->parentLocationId]);
9385

9486
return new RedirectResponse(
9587
$router->generate('ibexa.content.view', ['contentId' => $location->contentId,

bundle/Resources/config/services.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ services:
66
autoconfigure: true
77
public: false
88
bind:
9-
$httpCachePurgeClient: '@ibexa.http_cache.purge_client'
109
$entityManager: "@novaezprotectedcontent.doctrine.entity_manager"
1110

1211
Novactive\Bundle\eZProtectedContentBundle\Command\:

0 commit comments

Comments
 (0)