Enable autowiring in Hux classes
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3363433. -->
Reported by: [donquixote](https://www.drupal.org/user/459338)
Related to !22 !16
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>I like to use constructor injection with autowired parameters.<br>
See <a href="https://www.drupal.org/project/issues/drupal?text=autowire&status=All">https://www.drupal.org/project/issues/drupal?text=autowire&status=All</a></p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>All we need is this in HuxCompilerPass:</p>
<div class="codeblock">
<pre><span style="color: #000000"><span style="color: #0000BB"><?php<br> </span><span style="color: #007700">if ((new \</span><span style="color: #0000BB">ReflectionClass</span><span style="color: #007700">(</span><span style="color: #0000BB">$className</span><span style="color: #007700">))-></span><span style="color: #0000BB">isSubclassOf</span><span style="color: #007700">(</span><span style="color: #0000BB">ContainerInjectionInterface</span><span style="color: #007700">::class)) {<br> </span><span style="color: #0000BB">$definition<br> </span><span style="color: #007700">-></span><span style="color: #0000BB">setFactory</span><span style="color: #007700">([</span><span style="color: #0000BB">$className</span><span style="color: #007700">, </span><span style="color: #DD0000">'create'</span><span style="color: #007700">])<br> -></span><span style="color: #0000BB">setArguments</span><span style="color: #007700">([new </span><span style="color: #0000BB">Reference</span><span style="color: #007700">(</span><span style="color: #DD0000">'service_container'</span><span style="color: #007700">)]);<br> }<br> else {<br> </span><span style="color: #0000BB">$definition</span><span style="color: #007700">-></span><span style="color: #0000BB">setAutowired</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br> }<br></span><span style="color: #0000BB">?></span></span></pre></div>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<h3 id="summary-ui-changes">User interface changes</h3>
<h3 id="summary-api-changes">API changes</h3>
<h3 id="summary-data-model-changes">Data model changes</h3>
issue