Guite / MostGenerator

Transformation cartridges for generating Symfony bundles from ModuleStudio models.
https://modulestudio.de
23 stars 2 forks source link

Entity validation called in entity callbacks works (i.e. generates flashes), but doesn't stop the entity from being created / updated #698

Closed cmfcmf closed 8 years ago

Guite commented 8 years ago

Can you elaborate on which specific use case you tested that? From what I've seen so far entities are indeed stopped from being processed if a validation error occurs.

Guite commented 8 years ago

Some explanation about it should work.

The preSave callback executes the validate method and aborts if an error occurs: https://github.com/Guite/MostGenerator/blob/master/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/models/EventListener.xtend#L406

The actual validation is done here: https://github.com/Guite/MostGenerator/blob/master/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/models/entity/EntityMethods.xtend#L315 As you can see in lines 318 - 323 the flash bag is filled immediately before false is returned.

cmfcmf commented 8 years ago

I was editing routes with an earlier version of the Routes module. I think returning false from the entity callback didn't stop the creation.

Guite commented 8 years ago

Fixed in 997ed9d2130bff322a8f9ea0e4cdcf8861e458c1