sanitizeCollectedMessages example

class TranslationDataCollector extends DataCollector implements LateDataCollectorInterface
{
    private DataCollectorTranslator $translator;

    public function __construct(DataCollectorTranslator $translator)
    {
        $this->translator = $translator;
    }

    public function lateCollect(): void
    {
        $messages = $this->sanitizeCollectedMessages($this->translator->getCollectedMessages());

        $this->data += $this->computeCount($messages);
        $this->data['messages'] = $messages;

        $this->data = $this->cloneVar($this->data);
    }

    public function collect(Request $request, Response $response, \Throwable $exception = null): void
    {
        $this->data['locale'] = $this->translator->getLocale();
        $this->data['fallback_locales'] = $this->translator->getFallbackLocales();
    }
Home | Imprint | This part of the site doesn't use cookies.