getLanguageCodeToIdMapping example

throw new \RuntimeException('languages not initialized');
        }

        return $this->languages;
    }

    public function getLanguageId(string $identifier): ?string
    {
        if (Uuid::isValid($identifier)) {
            return $this->getLanguages()[mb_strtolower($identifier)]['id'] ?? null;
        }
        $mapping = $this->getLanguageCodeToIdMapping();

        return $mapping[mb_strtolower($identifier)] ?? null;
    }

    public static function createFromContext(Context $context): self
    {
        $self = new self($context);
        $self->set(LanguageDefinition::ENTITY_NAME, 'id', $context->getLanguageId());

        return $self;
    }

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