I need some help with my code. I am creating blocks dynamically using the plugin derivatives. I store some form data in a database table, then I display it in each block separately, depending on it's derivative id. My issue is: while, I do obtain all the individual blocks on a full clear cache, in the "Place Block" section, it's not there when I submit the form, basically, I would like the form submit function to trigger the derivative creation and it's discovery. Any suggestions appreciated.
Here's my Plugin Derivative code:
<?php
namespace Drupal\simpleads\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;
class SimpleAdsBlock extends DeriverBase
{
public function getDerivativeDefinitions($base_plugin_definition)
{
$query = \Drupal::database()
->select('simpleads_blocks', 'sb')
->fields('sb');
$results = $query->execute()->fetchAll();
foreach ($results as $result) {
$this->derivatives[$result->bid] = $base_plugin_definition;
$this->derivatives[$result->bid]['admin_label'] = $result->name;
}
return $this->derivatives;
}
}