Add logo.url and favicon.url to site data for code components
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3585314. -->
Reported by: [mglaman](https://www.drupal.org/user/2416470)
Related to !932
>>>
<h3 id="overview">Overview</h3>
<p><code>getSiteData()</code> in the <code>drupal-canvas</code> package exposes site branding (name, slogan, home URL) and <code>baseUrl</code>, but nothing about the active theme's logo or favicon. Components that want to render the site logo or favicon have no canonical path to those values through Canvas's data layer and must reach outside it.</p>
<p>On the PHP side, <code>\Drupal\canvas\CodeComponentDataProvider</code> already holds the pattern for exposing data via <code>drupalSettings.canvasData.v0.*</code>. A new method following that pattern can read theme settings using <code>theme_get_setting()</code> and push the results into <code>drupalSettings.canvasData.v0.themeAssets</code>.</p>
<h3 id="proposed-resolution">Proposed resolution</h3>
<p><strong>PHP <code>src/CodeComponentDataProvider.php</code></strong></p>
<p>Add a new method <code>getCanvasDataThemeAssetsV0()</code> that reads:</p>
<ul>
<li>Logo URL via <code>theme_get_setting('logo.url')</code></li>
<li>Favicon URL and MIME type via <code>theme_get_setting('favicon.url')</code> and <code>theme_get_setting('favicon.mimetype')</code></li>
</ul>
<p>Return shape:</p>
<pre><pre><span style="color: #000000"><span style="color: #0000BB"><?php<br></span><span style="color: #007700">[<br> </span><span style="color: #DD0000">'v0' </span><span style="color: #007700">=> [<br> </span><span style="color: #DD0000">'themeAssets' </span><span style="color: #007700">=> [<br> </span><span style="color: #DD0000">'logo' </span><span style="color: #007700">=> [<br> </span><span style="color: #DD0000">'url' </span><span style="color: #007700">=> </span><span style="color: #0000BB">string</span><span style="color: #007700">,<br> ],<br> </span><span style="color: #DD0000">'favicon' </span><span style="color: #007700">=> [<br> </span><span style="color: #DD0000">'url' </span><span style="color: #007700">=> </span><span style="color: #0000BB">string</span><span style="color: #007700">,<br> </span><span style="color: #DD0000">'mimeType' </span><span style="color: #007700">=> </span><span style="color: #0000BB">string</span><span style="color: #007700">,<br> ],<br> ],<br> ],<br>]<br></span><span style="color: #0000BB">?></span></span></pre></pre><p><strong>PHP <code>src/Hook/ComponentSourceHooks.php</code></strong></p>
<ol>
<li>Add <code>'canvas/canvasData.v0.themeAssets' => 'getCanvasDataThemeAssetsV0'</code> to <code>ASSET_LIBRARY_METHOD_MAPPING</code>.</li>
<li>Add the corresponding conditional block in <code>jsSettingsAlter()</code> following the existing pattern used for <code>branding</code>, <code>baseUrl</code>, etc.</li>
</ol>
<p><strong>TypeScript <code>packages/drupal-canvas/src/drupal-utils.ts</code></strong></p>
<ol>
<li>Extend the <code>SiteData</code> interface with a <code>themeAssets</code> field mirroring the PHP return shape.</li>
<li>Read <code>window.drupalSettings?.canvasData?.v0?.themeAssets</code> inside <code>getSiteData()</code> and include it in the returned object.</li>
</ol>
<h3 id="ui-changes">User interface changes</h3>
<p>None. This is a data-layer change only; no admin pages or forms are affected.</p>
issue