Argument #1 ($plugin_manager_block) must be of type Drupal\Core\Cache\CacheableDependencyInterface, Drupal\canvas\Block\BlockManagerDecorator given
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3580632. -->
Reported by: [f0ns](https://www.drupal.org/user/723426)
Related to !784
>>>
<h3 id="overview">Overview</h3>
<p>Since updating to 1.3.1 I get the following error:</p>
<p><code>Argument #1 ($plugin_manager_block) must be of type Drupal\Core\Cache\CacheableDependencyInterface, Drupal\canvas\Block\BlockManagerDecorator given</code></p>
<p>The error is thrown because of </p>
<pre>{{ drupal_block('webform_block', {webform_id: webform, lazy: true}) }}</pre><p>This is used in an SDC where I read out all the available webforms and I render them dynamically in Drupal Canvas (using Twig Tweak which introduces drupal_block).</p>
<p>I notice Canvas now introduced a BlockManagerDecorator.php (modules/contrib/canvas/src/Block/BlockManagerDecorator.php)</p>
<h3 id="proposed-resolution">Proposed resolution</h3>
<p>When I add </p>
<p><code>use Drupal\Core\Cache\CacheableDependencyInterface;</code></p>
<p>Add </p>
<p><code>CacheableDependencyInterface</code> to the list of implements</p>
<p>And add the following methods</p>
<pre> public function getCacheContexts() {<br> return $this->decorated->getCacheContexts();<br> }<br><br> public function getCacheTags() {<br> return $this->decorated->getCacheTags();<br> }<br><br> public function getCacheMaxAge() {<br> return $this->decorated->getCacheMaxAge();<br> }</pre><p>To the <code>BlockManagerDecorator.php</code> everything works fine again.</p>
<p>Is there a reason why this is not present in the current decorator and should I look for another solution or is this something we could add?</p>
> Related issue: [Issue #3001284](https://www.drupal.org/node/3001284)
> Related issue: [Issue #3580906](https://www.drupal.org/node/3580906)
issue