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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tedbow created an issue. See original summary.

tedbow’s picture

FileSize
3.04 KB

Not sure why patch didn't trigger tests. re-uploading

tim.plunkett’s picture

Title: Make BlockForm for Extensible » Make BlockForm extensible

I'd RTBC this, but it's actually my code from the other issue.

webchick’s picture

Status: Needs review » Reviewed & tested by the community

Looks straight-forward to me.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This is just shifting code around. Looks good to me. Committed d2c2e43 and pushed to 8.2.x. Thanks!

  • alexpott committed d2c2e43 on 8.2.x
    Issue #2774997 by tedbow, tim.plunkett: Make BlockForm extensible
    

  • alexpott committed d2c2e43 on 8.3.x
    Issue #2774997 by tedbow, tim.plunkett: Make BlockForm extensible
    

  • alexpott committed d2c2e43 on 8.3.x
    Issue #2774997 by tedbow, tim.plunkett: Make BlockForm extensible
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.