43 lines
1.7 KiB
PHP
43 lines
1.7 KiB
PHP
<?php
|
|
namespace ProVM\KI\Common\Controller\Web;
|
|
|
|
use Psr\Container\ContainerInterface as Container;
|
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
|
use Psr\Http\Message\ResponseInterface as Response;
|
|
use Slim\Views\Blade as View;
|
|
use Carbon\Carbon;
|
|
|
|
class Base {
|
|
public function __invoke(Request $request, Response $response, View $view, Container $container) {
|
|
$filename = implode(DIRECTORY_SEPARATOR, [
|
|
$container->get('folders.data'),
|
|
'avisos.json'
|
|
]);
|
|
$avisos = json_decode(trim(file_get_contents($filename)));
|
|
$filename = implode(DIRECTORY_SEPARATOR, [
|
|
$container->get('folders.data'),
|
|
'destacados.json'
|
|
]);
|
|
$destacados = json_decode(trim(file_get_contents($filename)));
|
|
$filename = implode(DIRECTORY_SEPARATOR, [
|
|
$container->get('folders.data'),
|
|
'segmentos.json'
|
|
]);
|
|
$segmentos = json_decode(trim(file_get_contents($filename)));
|
|
array_walk($segmentos, function(&$item) use ($container) {
|
|
if (!isset($item->imagen)) {
|
|
$item->imagen = '<div class="ui placeholder"><div class="square image"></div></div>';
|
|
return;
|
|
}
|
|
$item->imagen = '<img src="' . $container->get('urls')->images . '/' . $item->imagen . '" />';
|
|
});
|
|
$filename = implode(DIRECTORY_SEPARATOR, [
|
|
$container->get('folders.data'),
|
|
'resumen.json'
|
|
]);
|
|
$resumen = json_decode(trim(file_get_contents($filename)));
|
|
$indicadores = ['uf' => 'UF', 'euro' => 'Euro', 'imacec' => 'IMACEC', 'dolar' => 'USD', 'ipc' => 'IPC', 'utm' => 'UTM', 'bitcoin' => 'BitCoin', 'libra_cobre' => 'Lb. Cu'];
|
|
return $view->render($response, 'home', compact('aviso', 'avisos', 'destacados', 'segmentos', 'resumen', 'indicadores'));
|
|
}
|
|
}
|