public function getFieldStorageDefinitions() {
$definitions = [];
foreach (array_keys($this->pluginManager->getDefinitions()) as $plugin_id) {
/** @var \Drupal\entity\BundlePlugin\BundlePluginInterface $plugin */
$plugin = $this->pluginManager->createInstance($plugin_id);
There's no code that enforces that the plugin object actually implements BundlePluginInterface.
It would be good DX to add a check that $plugin instanceof BundlePluginInterface and throw an exception if not, so that a developer who's not added the interface gets a clear message about.
getFieldStorageDefinitions() is called only on rebuild, so it's not a performance cost.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3057208-3-bundle-plugin-assert.patch | 1.32 KB | bojanz |
Comments
Comment #2
bojanz commentedBetter title.
Core (and Commerce with the InlineForm API) usually does this via assertions.
Comment #3
bojanz commentedComment #5
bojanz commented