ai_content_suggestions - issue while adding blocks on landing pages
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3562615. -->
Reported by: [punamshelke](https://www.drupal.org/user/3509619)
Related to !1041
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Error: Call to undefined method Drupal\layout_builder\Form\AddBlockForm::getEntity() in Drupal\ai_content_suggestions\AiContentSuggestionsFormAlter->alter() (Zeile 40 in /mnt/www/html/syngentacpd901dev/docroot/modules/contrib/ai/modules/ai_content_suggestions/src/AiContentSuggestionsFormAlter.php).</p>
<h4 id="summary-steps-reproduce">Steps to reproduce (required for bugs, but not feature requests)</h4>
<p>1. Create landing page<br>
2. Add CTA blocks on that page</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>The error occurs because the code assumes all form objects have the getEntity() method, but AddBlockForm from Layout Builder doesn't. </p>
<p>1. Added a check to verify if the form object implements ContentEntityFormInterface<br>
2. Skip the current iteration if it's not a content entity form<br>
3. Added proper type checking before calling getEntity()</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<h3>Optional: Other details as applicable (e.g., User interface changes, API changes, Data model changes)</h3>
issue