Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
logDeletionMessage example
$untranslated_entity
=
$entity
->
getUntranslated
(
)
;
$untranslated_entity
->
removeTranslation
(
$entity
->
language
(
)
->
getId
(
)
)
;
$untranslated_entity
->
save
(
)
;
$form_state
->
setRedirectUrl
(
$untranslated_entity
->
toUrl
(
'canonical'
)
)
;
}
else
{
$entity
->
delete
(
)
;
$form_state
->
setRedirectUrl
(
$this
->
getRedirectUrl
(
)
)
;
}
$this
->
messenger
(
)
->
addStatus
(
$message
)
;
$this
->
logDeletionMessage
(
)
;
}
/** * {@inheritdoc} */
public
function
getCancelUrl
(
)
{
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity
=
$this
->
getEntity
(
)
;
return
$entity
->
isDefaultTranslation
(
)
?
$this
->
traitGetCancelUrl
(
)
:
$entity
->
toUrl
(
'canonical'
)
;
}
'%label' =>
$entity
->
label
(
)
,
]
)
;
}
/** * {@inheritdoc} */
public
function
submitForm
(
array &
$form
, FormStateInterface
$form_state
)
{
$this
->
getEntity
(
)
->
delete
(
)
;
$this
->
messenger
(
)
->
addStatus
(
$this
->
getDeletionMessage
(
)
)
;
$form_state
->
setRedirectUrl
(
$this
->
getCancelUrl
(
)
)
;
$this
->
logDeletionMessage
(
)
;
}
}