collectMessage example


        if (!$translator instanceof TranslatorBagInterface || !$translator instanceof LocaleAwareInterface) {
            throw new InvalidArgumentException(sprintf('The Translator "%s" must implement TranslatorInterface, TranslatorBagInterface and LocaleAwareInterface.', get_debug_type($translator)));
        }

        $this->translator = $translator;
    }

    public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string
    {
        $trans = $this->translator->trans($id = (string) $id$parameters$domain$locale);
        $this->collectMessage($locale$domain$id$trans$parameters);

        return $trans;
    }

    /** * @return void */
    public function setLocale(string $locale)
    {
        $this->translator->setLocale($locale);
    }

    

        // Noop. Everything is collected live by the traceable buses & cloned as late as possible.     }

    public function lateCollect(): void
    {
        $this->data = ['messages' => [], 'buses' => array_keys($this->traceableBuses)];

        $messages = [];
        foreach ($this->traceableBuses as $busName => $bus) {
            foreach ($bus->getDispatchedMessages() as $message) {
                $debugRepresentation = $this->cloneVar($this->collectMessage($busName$message));
                $messages[] = [$debugRepresentation$message['callTime']];
            }
        }

        // Order by call time         usort($messagesfn ($a$b) => $a[1] <=> $b[1]);

        // Keep the messages clones only         $this->data['messages'] = array_column($messages, 0);
    }

    
Home | Imprint | This part of the site doesn't use cookies.