Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getRawDestination example
}
/** * {@inheritdoc} */
public
function
import
(
Row
$row
, array
$old_destination_id_values
=
[
]
)
{
if
(
$this
->
isTranslationDestination
(
)
)
{
$this
->config =
$this
->language_manager->
getLanguageConfigOverride
(
$row
->
getDestinationProperty
(
'langcode'
)
,
$this
->config->
getName
(
)
)
;
}
foreach
(
$row
->
getRawDestination
(
)
as
$key
=>
$value
)
{
if
(
isset
(
$value
)
|| !
empty
(
$this
->configuration
[
'store null'
]
)
)
{
$this
->config->
set
(
str_replace
(
Row::PROPERTY_SEPARATOR, '.',
$key
)
,
$value
)
;
}
}
$this
->config->
save
(
)
;
$ids
[
]
=
$this
->config->
getName
(
)
;
if
(
$this
->
isTranslationDestination
(
)
)
{
$ids
[
]
=
$row
->
getDestinationProperty
(
'langcode'
)
;
}
return
$ids
;
}
if
(
!
$row
->
hasDestinationProperty
(
'property'
)
)
{
throw
new
\
LogicException
(
'The "property" property is required'
)
;
}
if
(
!
$row
->
hasDestinationProperty
(
'translation'
)
)
{
throw
new
\
LogicException
(
'The "translation" property is required'
)
;
}
$config_override
=
$this
->languageManager->
getLanguageConfigOverride
(
$row
->
getDestinationProperty
(
'langcode'
)
,
$config
)
;
$config_override
->
set
(
str_replace
(
Row::PROPERTY_SEPARATOR, '.',
$row
->
getDestinationProperty
(
'property'
)
)
,
$row
->
getDestinationProperty
(
'translation'
)
)
;
$config_override
->
save
(
)
;
}
else
{
foreach
(
$row
->
getRawDestination
(
)
as
$property
=>
$value
)
{
$this
->
updateEntityProperty
(
$entity
,
explode
(
Row::PROPERTY_SEPARATOR,
$property
)
,
$value
)
;
}
$this
->
setRollbackAction
(
$row
->
getIdMap
(
)
)
;
}
}
/** * Updates a (possible nested) entity property with a value. * * @param \Drupal\Core\Entity\EntityInterface $entity * The config entity. * @param array $parents * The array of parents. * @param string|object $value * The value to update to. */