<?php
namespace Incoviba\Controller\Inmobiliarias;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Common\Alias\View;
use Incoviba\Repository;
use Incoviba\Service;

class Proveedores
{
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view,
                             Service\Inmobiliaria\Proveedor $proveedorService): ResponseInterface
    {
        $proveedores = [];
        try {
            $proveedores = $proveedorService->getAll('nombre');
        } catch (EmptyResult) {}
        return $view->render($response, 'inmobiliarias.proveedores', compact('proveedores'));
    }
}
