Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
swapDefaultLanguageId example
foreach
(
$defaultCountryStateTranslations
as
$shortCode
=>
$deTranslation
)
{
if
(
!\
array_key_exists
(
$shortCode
,
$correctDeTranslations
)
)
{
continue
;
}
$defaultCountryStateTranslations
[
$shortCode
]
=
$correctDeTranslations
[
$shortCode
]
;
}
}
$this
->
swapDefaultLanguageId
(
$newDefaultLanguageId
)
;
$this
->
addMissingCountryStates
(
$defaultCountryStateTranslations
)
;
}
else
{
$this
->
changeDefaultLanguageData
(
$newDefaultLanguageId
,
$currentLocale
,
$locale
)
;
}
}
public
function
setDefaultCurrency
(
string
$currencyCode
)
: void
{
$currentCurrencyIso
=
$this
->connection->
fetchOne
(
'SELECT iso_code FROM currency WHERE id = :currencyId',
[
'currencyId' => Uuid::
fromHexToBytes
(
Defaults::CURRENCY
)
]
)
;
public
function
testNewMailTemplatesAreAddedWithGermanAsDefault
(
)
: void
{
// Rollback migration data and make sure its gone
$this
->
rollbackMigrationChanges
(
)
;
static
::
assertEmpty
(
$this
->
getMailTemplateTypeId
(
)
)
;
$this
->connection->
executeStatement
(
'SET FOREIGN_KEY_CHECKS = 0;'
)
;
$this
->connection->
executeStatement
(
'DELETE FROM language WHERE id != UNHEX(?)',
[
Defaults::LANGUAGE_SYSTEM
]
)
;
$this
->connection->
executeStatement
(
'SET FOREIGN_KEY_CHECKS = 1;'
)
;
$languageId
=
$this
->
createNewLanguageEntry
(
'de-DE'
)
;
$this
->
swapDefaultLanguageId
(
$languageId
)
;
// Rerun migration and make sure everything is added again
$migration
=
new
Migration1672931011ReviewFormMailTemplate
(
)
;
$migration
->
update
(
$this
->connection
)
;
$mailTemplateTypeId
=
$this
->
getMailTemplateTypeId
(
)
;
static
::
assertNotNull
(
$mailTemplateTypeId
)
;
static
::
assertNotNull
(
$this
->
getMailTemplateId
(
$mailTemplateTypeId
)
)
;
}
private
function
rollbackMigrationChanges
(
)
: void
{