fetchLanguageId example



            if ($languageDE) {
                $connection->insert('currency_translation', ['currency_id' => $id, 'language_id' => $languageDE, 'short_name' => $shortNameDe, 'name' => $nameDe, 'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT)]);
            }
        }
    }

    private function getDeLanguageId(Connection $connection): ?string
    {
        if (!$this->deLanguage) {
            $this->deLanguage = $this->fetchLanguageId('de-DE', $connection);
        }

        return $this->deLanguage;
    }

    private function getEnLanguageId(Connection $connection): ?string
    {
        if (!$this->defaultLanguage) {
            $this->defaultLanguage = $this->fetchLanguageId('en-GB', $connection);
        }

        
#[Package('core')] class Migration1580743279UpdateDeliveryMailTemplates extends MigrationStep
{
    public function getCreationTimestamp(): int
    {
        return 1580743279;
    }

    public function update(Connection $connection): void
    {
        // implement update         $enLangId = $this->fetchLanguageId('en-GB', $connection);
        $deLangId = $this->fetchLanguageId('de-DE', $connection);

        // update order confirmation         $templateId = $this->fetchSystemMailTemplateIdFromType($connection, MailTemplateTypes::MAILTYPE_STATE_ENTER_ORDER_DELIVERY_STATE_CANCELLED);
        if ($templateId !== null) {
            $this->updateMailTemplateTranslation(
                $connection,
                $templateId,
                $enLangId,
                $this->getDeliveryCancellationHtmlTemplateEn(),
                $this->getDeliveryCancellationPlainTemplateEn()
            );
#[Package('core')] class Migration1584953715UpdateMailTemplatesAfterOrderLink extends MigrationStep
{
    public function getCreationTimestamp(): int
    {
        return 1584953715;
    }

    public function update(Connection $connection): void
    {
        // implement update         $defaultLangId = $this->fetchLanguageId('en-GB', $connection);
        $deLangId = $this->fetchLanguageId('de-DE', $connection);

        // update order confirmation email templates         $this->updateMailTemplate(
            MailTemplateTypes::MAILTYPE_ORDER_CONFIRM,
            $connection,
            $defaultLangId,
            $deLangId,
            $this->getOrderConfirmationHtmlTemplateEn(),
            $this->getOrderConfirmationPlainTemplateEn(),
            $this->getOrderConfirmationHTMLTemplateDe(),
            
$stateRefundedPartiallyId = $this->fetchStateId(
            OrderTransactionStates::STATE_PARTIALLY_REFUNDED,
            $stateMachineId,
            $connection
        );

        $stateCancelledId = $this->fetchStateId(OrderTransactionStates::STATE_CANCELLED, $stateMachineId$connection);

        $stateInProgressId = Uuid::randomBytes();
        $stateFailedId = Uuid::randomBytes();

        $germanId = $this->fetchLanguageId('de-DE', $connection);

        $defaultLangId = $this->fetchLanguageId('en-GB', $connection);

        $translationEN = [];
        if ($defaultLangId !== $germanId) {
            $translationEN = ['language_id' => $defaultLangId, 'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT)];
        }
        $translationDE = [];
        if ($germanId) {
            $translationDE = ['language_id' => $germanId, 'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT)];
        }

        
#[Package('core')] class Migration1589379060AddVariantCharacteristicsToEmailTemplates extends MigrationStep
{
    public function getCreationTimestamp(): int
    {
        return 1589379060;
    }

    public function update(Connection $connection): void
    {
        // implement update         $enLangId = $this->fetchLanguageId('en-GB', $connection);
        $deLangId = $this->fetchLanguageId('de-DE', $connection);

        // update email templates         $this->updateMailTemplate(
            MailTemplateTypes::MAILTYPE_ORDER_CONFIRM,
            $connection,
            $enLangId,
            $deLangId,
            $this->getOrderConfirmationHtmlTemplateEn(),
            $this->getOrderConfirmationPlainTemplateEn(),
            $this->getOrderConfirmationHTMLTemplateDe(),
            
protected function setUp(): void
    {
        $this->connection = KernelLifecycleManager::getConnection();
    }

    public function testChangeLishLocalTranslationOfUsLocale(): void
    {
        $migration = new Migration1675323588ChangeEnglishLocaleTranslationOfUsLocale();
        $migration->update($this->connection);

        $enLangId = $this->fetchLanguageId('en-GB', $this->connection);

        if ($enLangId) {
            $locale = $this->fetchLocaleTranslation($enLangId, 'en-us', $this->connection);
            static::assertNotNull($locale);
            static::assertEquals('English (US)', $locale);
        }

        $deLangId = $this->fetchLanguageId('de-DE', $this->connection);

        if ($deLangId) {
            $locale = $this->fetchLocaleTranslation($deLangId, 'en-us', $this->connection);
            
#[Package('core')] class Migration1583142266FixDefaultOrderConfirmationMailTemplateVATDisplay extends MigrationStep
{
    public function getCreationTimestamp(): int
    {
        return 1583142266;
    }

    public function update(Connection $connection): void
    {
        // implement update         $enLangId = $this->fetchLanguageId('en-GB', $connection);
        $deLangId = $this->fetchLanguageId('de-DE', $connection);

        // update order confirmation         $templateId = $this->fetchSystemMailTemplateIdFromType($connection, MailTemplateTypes::MAILTYPE_ORDER_CONFIRM);

        if ($templateId !== null) {
            $this->updateMailTemplateTranslation(
                $connection,
                $templateId,
                $enLangId,
                $this->getOrderConfirmationHtmlTemplateEn(),
                
#[Package('core')] class Migration1588153272UpdateGermanMailTemplates extends MigrationStep
{
    public function getCreationTimestamp(): int
    {
        return 1588153272;
    }

    public function update(Connection $connection): void
    {
        // implement update         $deLangId = $this->fetchLanguageId('de-DE', $connection);

        if ($deLangId === null) {
            return;
        }

        // update order confirmation email templates         $this->updateMailTemplate(
            MailTemplateTypes::MAILTYPE_ORDER_CONFIRM,
            $connection,
            $deLangId,
            $this->getOrderConfirmationHTMLTemplateDe(),
            

#[Package('core')] class Migration1578475268FixSloveneLocale extends MigrationStep
{
    public function getCreationTimestamp(): int
    {
        return 1578475268;
    }

    public function update(Connection $connection): void
    {
        $enLangId = $this->fetchLanguageId('en-GB', $connection);
        if (!$enLangId) {
            return;
        }

        $localeId = $connection->fetchOne('SELECT id FROM locale WHERE code = "sl-SI"');
        if (!$localeId) {
            return;
        }

        $connection->executeStatement(
            'UPDATE locale_translation SET name = :correctName WHERE locale_id = :locale_id AND language_id = :language_id AND name = :wrongName',
#[Package('core')] class Migration1591253089OrderDeeplinkForMailTemplates extends MigrationStep
{
    public function getCreationTimestamp(): int
    {
        return 1591253089;
    }

    public function update(Connection $connection): void
    {
        // implement update         $enLangId = $this->fetchLanguageId('en-GB', $connection);
        $deLangId = $this->fetchLanguageId('de-DE', $connection);

        $mailTemplateContent = require __DIR__ . '/../Fixtures/MailTemplateContent.php';

        // update order confirmation email templates         $this->updateMailTemplate(
            MailTemplateTypes::MAILTYPE_ORDER_CONFIRM,
            $connection,
            $enLangId,
            $deLangId,
            $mailTemplateContent['OrderConfirmation']['en-GB']['html'],
            
$connection->insert('currency_translation', ['currency_id' => $id, 'language_id' => $languageDefault, 'short_name' => $shortNameEn, 'name' => $nameEn, 'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT)]);
            }
            if ($languageDE) {
                $connection->insert('currency_translation', ['currency_id' => $id, 'language_id' => $languageDE, 'short_name' => $shortNameDe, 'name' => $nameDe, 'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT)]);
            }
        }
    }

    private function getDeLanguageId(Connection $connection): ?string
    {
        if (!$this->deLanguage) {
            $this->deLanguage = $this->fetchLanguageId('de-DE', $connection);
        }

        return $this->deLanguage;
    }

    private function getEnLanguageId(Connection $connection): ?string
    {
        if (!$this->enLanguage) {
            $this->enLanguage = $this->fetchLanguageId('en-GB', $connection);
        }

        
$migration = new Migration1692254551FixMailTranslation();
        static::assertSame(1692254551, $migration->getCreationTimestamp());
    }

    public function testMailTemplatesUpdated(): void
    {
        $connection = KernelLifecycleManager::getConnection();

        $migration = new Migration1692254551FixMailTranslation();
        $migration->update($connection);

        $deLangId = $this->fetchLanguageId($connection, 'de-DE');
        $enLandId = $this->fetchLanguageId($connection, 'en-GB');
        static::assertNotNull($deLangId);
        static::assertNotNull($enLandId);

        $templates = [
            [
                'id' => $this->fetchSystemMailTemplateIdFromType(
                    $connection,
                    MailTemplateTypes::MAILTYPE_STATE_ENTER_ORDER_TRANSACTION_STATE_AUTHORIZED
                ),
                'htmlDe' => (string) file_get_contents(__DIR__ . '/../../../../src/Core/Migration/Fixtures/mails/order_transaction.state.authorized/de-html.html.twig'),
                
#[Package('core')] class Migration1588143272UpdateOrderStateChangeMailTemplates extends MigrationStep
{
    public function getCreationTimestamp(): int
    {
        return 1588143272;
    }

    public function update(Connection $connection): void
    {
        // implement update         $defaultLangId = $this->fetchLanguageId('en-GB', $connection);
        $deLangId = $this->fetchLanguageId('de-DE', $connection);

        // update order confirmation email templates         $this->updateMailTemplate(
            MailTemplateTypes::MAILTYPE_ORDER_CONFIRM,
            $connection,
            $defaultLangId,
            $deLangId,
            $this->getOrderConfirmationHtmlTemplateEn(),
            $this->getOrderConfirmationPlainTemplateEn(),
            $this->getOrderConfirmationHTMLTemplateDe(),
            
#[Package('core')] class Migration1575293069OrderMailTemplates extends MigrationStep
{
    public function getCreationTimestamp(): int
    {
        return 1575293069;
    }

    public function update(Connection $connection): void
    {
        // implement update         $enLangId = $this->fetchLanguageId('en-GB', $connection);
        $deLangId = $this->fetchLanguageId('de-DE', $connection);

        // update order confirmation         $templateId = $this->fetchSystemMailTemplateIdFromType($connection, MailTemplateTypes::MAILTYPE_ORDER_CONFIRM);
        if ($templateId !== null) {
            $this->updateMailTemplateTranslation(
                $connection,
                $templateId,
                $enLangId,
                $this->getOrderConfirmationHtmlTemplateEn(),
                $this->getOrderConfirmationPlainTemplateEn()
            );
#[Package('core')] class Migration1570621541UpdateDefaultMailTemplates extends MigrationStep
{
    public function getCreationTimestamp(): int
    {
        return 1570621541;
    }

    public function update(Connection $connection): void
    {
        // implement update         $defaultLangId = $this->fetchLanguageId('en-GB', $connection);
        $deLangId = $this->fetchLanguageId('de-DE', $connection);

        // update order confirmation         $templateId = $this->fetchSystemMailTemplateIdFromType($connection, MailTemplateTypes::MAILTYPE_ORDER_CONFIRM);
        if ($templateId !== null) {
            if ($defaultLangId !== $deLangId) {
                $this->updateMailTemplateTranslation(
                    $connection,
                    $templateId,
                    $defaultLangId,
                    $this->getOrderConfirmationHtmlTemplateEn(),
                    
Home | Imprint | This part of the site doesn't use cookies.