I have Symfony 2.8. I use SonataAdminBundle v2.3 + a2lix/TranslationFormBundle v2.1 + SonataMediaBundle v2.3. I have NewsAdmin
class:
class NewsAdmin extends Admin
{
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('translations', 'a2lix_translations', ['fields' => [
'content' => [
'field_type' => 'ckeditor',
]
]])
->add('excerptImage', 'sonata_type_model_list', [], [
'link_parameters' => ['context' => 'default'],
'require' => false
])
->add('excerptImageSide')
->add('category', 'sonata_type_model', [
'class' => 'AppBundle\Entity\NewsCategory',
'property' => 'shortName'
])
;
}
// configureDatagridFilters(), configureListFields() ...
// Does not firing!
public function postUpdate($news)
{
dump('preUpdate');
}
// Does not firing!
public function prePersist($news)
{
dump('prePersist');
}
}
The problem is that nor postUpdate
, nor prePersist
methods are not firing, so I don't see in web profiler string 'preUpdate' or 'prePersist'. Why that happens? And how to fix that?
PS Please, let me know if you need more information.
Just add a die
and you'll see your dump
.
public function prePersist($news)
{
dump('prePersist');
die;
}
EDIT
That's because the dump
is not called directly from the controller action that renders the view, nor from a method called by the action, but in an EventListener that is totally standalone.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.