<?php
/**
 * AUX Card Group template
 *
 * @param \WP_Post[] $featureItems The block settings and attributes.
 */

use WP_AUX\Entities\AuxFramework\Partials\IconListEntity;
use WP_AUX\Services\AuxCF\BlocksService;

// Set component variables from user input
$iconListItems = aux_get_field('icon_list');

$iconList =  '';

// Create link list from user input
if ($iconListItems) {
  $iconList = IconListEntity::create();
  $iconList->setColumns(aux_get_field('icon_list_columns'));

  // Loop through top-level link items to add to link list
  foreach ($iconListItems as $iconListItem) {
    $iconList->addItem(
      $iconListItem['icon_list_icon'],
      $iconListItem['icon_list_item_text'],
      $iconListItem['icon_list_desc']
    );
  }
}

$section = BlocksService::getSection('icon-list-collection');
$section->setContent((string) $iconList);

echo $section;
