Use async requests on generateSgv
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3453127. -->
Reported by: [alvar0hurtad0](https://www.drupal.org/user/1564318)
Related to !14
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>When the cache is empty, the search in the field type takes too long. The problem is the HUGE amount of API calls we need to use in order to show the preview.</p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>Just Remove the cache in public::/iconify-icons, and try to add any content in an iconify field.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Use async capabilities of PHP (read this <a href="https://gorannikolovski.com/blog/asynchronous-and-concurrent-http-requests-in-php">https://gorannikolovski.com/blog/asynchronous-and-concurrent-http-requests-in-php</a>)</p>
<p>In the generateSvg we should pass an array of icon names, so:<br>
<code> public function generateSvg(string $collection, string $icon_name, array $parameters = []): string {</code><br>
should be moved to<br>
<code> public function generateSvg(string $collection, array $icons, array $parameters = []): string {</code></p>
<p>So we should pass into the $icons paramater all the icons that belongs to the same collection.</p>
<p>Inside the method:</p>
<p>We should do all the API requests asynchronously (using a loop), and wait for all the promises.</p>
issue