In #2753941: [Experimental] Create Outside In module MVP to provide block configuration in Off-Canvas tray and expand site edit mode we are trying to use the new functionality in #2763157: Allow plugins to provide multiple forms to provide a new "offcanvas" form handler for the block entity. This form handler would not include some of the block elements such as visibility and would use the "offcanvas" plugin form for the related Block plugin if available.
To do this we are extending the class \Drupal\block\BlockForm. But BlockForm in submitForm assumes that visibility settings will always be on the form. A class extending BlockForm cannot simply override submitForm because it needs to call parent::submitForm unless it is going duplicate \Drupal\Core\Entity\EntityForm::submitForm. Which would be a bad idea ;)
This patches refactors the visibility logic in submitForm to the new function submitVisibility. This allows any class that extends BlockForm to override submitVisibility with an empty function if they do not include visibility in the block form.
It should be noted that Block already has separate functions for validateVisibility and buildVisibilityInterface. But not submit.
Since this is an internal refactoring all existing block tests should pass.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2774997-block_extensible-2.patch | 3.04 KB | tedbow |
Comments
Comment #2
tedbowNot sure why patch didn't trigger tests. re-uploading
Comment #3
tim.plunkettI'd RTBC this, but it's actually my code from the other issue.
Comment #4
webchickLooks straight-forward to me.
Comment #5
alexpottThis is just shifting code around. Looks good to me. Committed d2c2e43 and pushed to 8.2.x. Thanks!