Skip to content

Expand the example showing how to inject PurgeClientInterface#3287

Merged
mnocon merged 1 commit into
5.0from
inject-purgeclient
Jul 13, 2026
Merged

Expand the example showing how to inject PurgeClientInterface#3287
mnocon merged 1 commit into
5.0from
inject-purgeclient

Conversation

@mnocon

@mnocon mnocon commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Target: 5.0, 6.0

As reported on community Slack:

ok, i have a puzzler about the PurgeCache, I'm trying to create an App\Event\Subscriber\PublishVersion\MyContentOnPublishVersionSubscriber.php class that will clear the cache under specific conditions.

according https://doc.ibexa.co/en/latest/infrastructure_and_maintenance/cache/http_cache/content_aware_cache/#custom-purging-from-code I need the

/** @var \Ibexa\Contracts\HttpCache\PurgeClient\PurgeClientInterface $purgeClient */

I tried to autowire the PurgeClientInterface $purgeClient but that fails for both the __construct() and the onPublishVersionEvent(PublishVersionEvent $event)

The only way i've been able to get the $purgeClient is via service declaration.

services:
    App\Event\Subscriber\PublishVersion\NavItemOnPublishVersionSubscriber:
        arguments:
            $purgeClient: '@ibexa.http_cache.purge_client'

The current version of the doc doesn't tell how to inject the PurgeClient, and it cannot be autowired.

The example is expanded to show the name of the service that needs to be injected.
I've used invokable command with the Autowire attirubte to have a standalone, complete example

Tested locally that it works:

~/Desktop/Sites/v5 main +1 !174 ?16 ❯ php bin/console app:purge-cache                                                                                                                            6s  24.4.0 10:19:42


 [OK] Purging cache...

@github-actions

Copy link
Copy Markdown

Preview of modified files

Preview of modified Markdown:

@mnocon mnocon marked this pull request as ready for review July 13, 2026 08:42
@mnocon mnocon requested a review from a team July 13, 2026 08:42
@github-actions

Copy link
Copy Markdown

Summary

Status Count
🔍 Total 758335
🔗 Unique 15014
✅ Successful 7267
⏳ Timeouts 0
🔀 Redirected 0
👻 Excluded 751068
❓ Unknown 0
🚫 Errors 0
⛔ Unsupported 0

Full Github Actions output

@mnocon mnocon requested a review from a team July 13, 2026 09:35
@ibexa-workflow-automation-1 ibexa-workflow-automation-1 Bot requested review from adriendupuis, dabrt and julitafalcondusza and removed request for a team July 13, 2026 09:35
@mnocon mnocon merged commit 260b6a4 into 5.0 Jul 13, 2026
26 checks passed
@mnocon mnocon deleted the inject-purgeclient branch July 13, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants