---
title: "Events"
manual: "Myra Cloud Connector"
version: "4.2"
permalink: "https://docs.typo3.org/permalink/cpsit/myra-cloud-connector:events@4.2"
source: "Reference/Events.rst"
rendered: "2026-11-05T07:30:46+00:00"
---

# Events {#events}

## ClearMyraCloudCacheEvent {#clear-myra-cloud-cache-event}

<!-- TODO: no Markdown rendering for "versionadded" -->

Feature #155 - Introduce and use ClearMyraCloudCacheEvent for cache flush

`\CPSIT\MyraCloudConnector\Event\ClearMyraCloudCacheEvent` is a PSR-14
event dispatched by every built-in trigger of a Myra Cloud cache clear
request:

-   the [CLI command](https://docs.typo3.org/permalink/cpsit/myra-cloud-connector:cli-command@4.2)
-   the backend AJAX endpoint used by the clear-cache buttons, the clear-cache
    menu entries and the context menu action
-   the AutoClear hooks ([page update](https://docs.typo3.org/permalink/cpsit/myra-cloud-connector:page-update-hook@4.2) and
    [file replace](https://docs.typo3.org/permalink/cpsit/myra-cloud-connector:file-replace-hook@4.2))

```php
final class ClearMyraCloudCacheEvent
{
    public function __construct(
        public readonly Typo3CacheType $type,
        public readonly ?string $identifier = null,
        public readonly ?int $languageId = null,
    ) {}

    public function getCacheResult(): ?bool;
    public function setCacheResult(bool $result): void;
}
```

`type`, `identifier` and `languageId` describe what should be
cleared (see [CLI command](https://docs.typo3.org/permalink/cpsit/myra-cloud-connector:cli-usage@4.2) for the meaning of these values
per type). A listener is expected to report the outcome of the clear request
via `setCacheResult()`; callers read it back via `getCacheResult()`.

## Default listener {#clear-myra-cloud-cache-event-default-listener}

`\CPSIT\MyraCloudConnector\EventListener\ExternalClearCacheListener` is
registered by default. It resolves the affected page (for the `page` type
when no explicit language is given), forwards the request to the configured
Myra adapter, de-duplicates repeated requests for the same
identifier/language within a request via the TYPO3 runtime cache, and
reports the result back on the event.

## Custom listeners {#clear-myra-cloud-cache-event-usage}

Register an additional listener on `ClearMyraCloudCacheEvent` (via
`#[AsEventListener]` or [`Configuration/Services.yaml`](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/FileStructure/Configuration/ServicesYaml.html#file-extension-configuration-services-yaml)) to react to
a clear request, for example to clear an additional external cache alongside
Myra Cloud, or to log specific requests.
