protected function getLanguageCode(ContentType $contentType)
    {
        $contentTypeLanguages = array_keys($contentType->getNames());

        foreach ($this->languages as $languageCode) {
            if (in_array($languageCode, $contentTypeLanguages, true)) {
                return $languageCode;
            }
        }

        return $contentType->mainLanguageCode;
    }