<?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\Config;
defined('_JEXEC') or die;
use DJExtensions\DJCatalog2\YOOtheme\Builder\Source\ItemHelper;
use YOOtheme\Http\Request;
use YOOtheme\Http\Response;
class ExtraFieldsController
{

	/**
	 * @param Request  $request
	 * @param Response $response
	 *
	 * @throws \Exception
	 *
	 * @return Response
	 */
	public static function getExtraField(Request $request, Response $response)
	{
		$type = $request->getParam('type');

		error_reporting(E_ALL);
		try {

			$fields = ItemHelper::getExtraFieldType($type);
			return $response->withJson($fields);
		} catch (\Exception $e) {
			$request->abort(400, $e->getMessage());
			print_r($e);
		}
	}

}
