<?php
/**
 * @package DJ-Catalog2-Yootheme
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 */

namespace DJExtensions\DJCatalog2\YOOtheme\Builder\Source;
defined('_JEXEC') or die;
use YOOtheme\Http\Request;
use YOOtheme\Http\Response;

class SourceController
{
	/**
	 * @param Request  $request
	 * @param Response $response
	 *
	 * @throws \Exception
	 *
	 * @return Response
	 */
	public static function producers(Request $request, Response $response)
	{
		$titles = [];
		foreach (ProducerHelper::get($request('ids')) as $producer) {
			$titles[$producer->id] = $producer->name;
		}
		return $response->withJson((object) $titles);
	}
}
