Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The core implementation of blocks is mostly tied up in the block entities and UI.
The actual plugin interfaces and managers are minimal amounts of code, but moving them would unblock #2309715: Several views still say they depend on block module but not anymore, and would allow code like https://www.drupal.org/project/page_manager to not depend on the block.module directly.
Proposed resolution
Move BlockPluginInterface/BlockBase and BlockManagerInterface/BlockManager to Drupal\Core\Block.
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#25 | interdiff.txt | 9.32 KB | tim.plunkett |
#25 | 2315333-block-25.patch | 45.68 KB | tim.plunkett |
Comments
Comment #1
tim.plunkettComment #2
Gábor HojtsyHow would this unblock #2309715: Several views still say they depend on block module but not anymore?
Comment #4
tim.plunkettWe can move the views integration now, and then the config won't depend on a missing module.
I accidentally included the preview issue in that last patch.
Comment #6
tim.plunkettUgh, what is wrong with phpstorm today?
Comment #7
EclipseGc CreditAttribution: EclipseGc commentedOther than the overzealous phpstorm driven refactor issue here, I'm quite ++ to this effort. Yes please!
Comment #9
tim.plunkettYeah, it's been strange today. Deleting some dead code in _language_disable_language_switcher(), and fixing NegotiationConfigureForm::disableLanguageSwitcher() to not call _block_rehash directly.
Comment #11
tim.plunkettToday is not my day.
Comment #12
dawehnerMoving Block to views sounds sane! But this should move the test file as well.
Comment #13
catchWhile it's has moved away from the approach that prompted the comment, this would help resolve some of the stuff I brought up in #2031859-53: Invoke an event[s] when a plugin ID disappears.
We might want to document that modules providing plugins should do so via an API module and not lumped in with the UI, or is this mainly a case of block module being simultaneously required and often replaced?
Comment #14
effulgentsia CreditAttribution: effulgentsia commentedI guess the question is when is there a reason to not want a UI-providing module installed. For example, image.module and filter.module (and many others in core) provide both plugins and a UI. If someone wants to disable the image style configuration UI or the text format configuration UI (or provide completely alternate ones), but still keep image effects and text filters at an API level, they can do so in various ways without needing the modules to be uninstalled. But, for that matter, I think the same is true of block.module. So maybe it comes down to a cost/benefit analysis of how common is the use case to not want the default UI vs. how much unwanted overhead is there in the unwanted UI's module being installed? Block UI, Views UI, and Field UI seem to be on the, yeah let's separate side of the line, but not sure about how many others in core and contrib need to be.
Comment #15
tim.plunkettThe problematic/undesirable parts of block.module is not the UI, but block_page_build(), hence #2295363: Blocks should be added to the page via an HtmlFragmentRenderer
Comment #16
effulgentsia CreditAttribution: effulgentsia commented@tim.plunkett: well, yes, overly obtrusive hook implementations are a problem. But are you saying that once that issue is fixed that this one becomes unnecessary? Or is this one still justified on the grounds of block plugins being such a common dependency for so many core modules (whereas, e.g., image effects are not)?
For completeness, I'll point out that we actually have 3 layers:
And once this issue lands, each of the blocks, views, and fields use cases will use a different permutation of how these are split:
I don't think the above differences are necessarily a problem (each one, considered on its own, is pretty rational), just pointing them out.
Comment #17
tim.plunkettI think we still need this. I agree with the 3 layers analysis, and ideally everything would be split in 3, but the block approach of plugin and entity/ui split is better than the views plugin/entity and ui split, IMO.
Comment #18
Gábor HojtsyLooks like the only thing outstanding here is #12?
Comment #19
tim.plunkettYep
Comment #23
tim.plunkettWhoops
Comment #24
dawehnerI guess we have to bits of block.api.php as well?
it is a pity that we cannot use the parent plugin manager here.
This is not longer needed!
Use statement not needed.
The test should be moved as well.
So the annotation has to be moved as well ...
This use statement is not needed.
This is NOT the proper way to get the default theme. \Drupal\Core\Extension\ThemeHandler->getDefaultTheme() is
This use statement is not needed.
Comment #25
tim.plunkettThanks for the great feedback!
I hope you don't mind my addition to ThemeHandlerInterface.
Comment #26
dawehner+1
Comment #27
Wim LeersPatch looks good, and that dead code removal hunk is great catch :)
Comment #28
alexpottCommitted 7f2710b and pushed to 8.0.x. Thanks!
Fixed on commit.
Comment #30
Gábor HojtsyActually, core views should have been updated as well, but I already have a patch for that at #2309715: Several views still say they depend on block module but not anymore :)