public function getLocale($document)
    {
        if ($document instanceof LocaleBehavior) {
            return $document->getLocale();
        }

        if ($this->documentRegistry->hasDocument($document)) {
            return $this->documentRegistry->getLocaleForDocument($document);
        }

        return;
    }