Refactor `ApiLayoutController` to support `ContentTemplate`s
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3541021. -->
Reported by: [tedbow](https://www.drupal.org/user/240860)
Related to !9 !1458 !1439 !1438
>>>
<h3 id="overview">Overview</h3>
<p>For <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3541000" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3541000</a></span> we will need to make content template in the XB UI</p>
<h3 id="proposed-resolution">Proposed resolution</h3>
<p>We will refactor ApiLayoutController to support ContentTemplate entities. The controller will not actually support rendering the templates with dynamic prop sources as this blocked by <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3513590" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3513590</a></span>. And the UI for setting them well be done in <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/canvas/issues/3541037" title="Status: Closed (fixed)">#3541037: Allow linking `ContentTemplate` SDC/code component instance props to fields (aka finally use `DynamicPropSource`s!)</a></span>. Rendering of these will be done in <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/canvas/issues/3541057" title="Status: Closed (fixed)">#3541057: Render `DynamicPropSource`s in `ApiLayoutController` for `ContentTemplate`s using the provided preview entity</a></span>. </p>
<p>This issue should be enough for the front-end to make the UI for creating templates without dynamic sources</p>
<p>So this issue will handle the GET, POST, and PATCH of the controller which should allow the UI work to be done in follow-up issues.</p>
<p>We will have tests that prove GET, POST, and PATCH as well as publishing. Fuller tests will be added/updated <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/canvas/issues/3543834" title="Status: Closed (fixed)">#3543834: Refactor (or attempt to) all or most `ApiLayoutController*Test` classes to also test `ContentTemplate` entities</a></span></p>
<p>We will remove the requirement for ContentTemplates to have a dynamic prop source to allow the front-end work to proceed without this requirement. This will be added back in <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-5"><a href="https://www.drupal.org/project/canvas/issues/3541054" title="Status: Closed (won't fix)">#3541054: Require `ContentTemplate`s to have at least one `dynamic` or `host-entity-url` prop source</a></span></p>
<h3 id="ui-changes">User interface changes</h3>
<p>None</p>
> Related issue: [Issue #3543834](https://www.drupal.org/node/3543834)
> Related issue: [Issue #3541000](https://www.drupal.org/node/3541000)
issue