62 lines
2.1 KiB
PHP
62 lines
2.1 KiB
PHP
<?php
|
|
namespace ProVM\NotariaRaby\Common\Controller\Web;
|
|
|
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
|
use Psr\Http\Message\ResponseInterface as Response;
|
|
use Psr\Container\ContainerInterface as Container;
|
|
use Slim\Views\Blade as View;
|
|
use ProVM\Common\Service\Filemanager;
|
|
|
|
class Home {
|
|
public function __invoke(Request $request, Response $response, View $view, Filemanager $manager, Container $container): Response {
|
|
$banner = (object) [
|
|
'titulo' => "5° NOTARÍA DE SANTIAGO\nPATRICIO RABY BENAVENTE",
|
|
'contenido' => "Gertrudis Echenique 30, of. 32, El Golf\n<i class=\"large icon icon-metro\"></i> Metro Alcantara"
|
|
];
|
|
|
|
$links = $manager->folder('data')->load('documentos.yml');
|
|
array_walk($links->documentos, function(&$item) use ($container) {
|
|
$item = new Documento($container, $item->texto, $item->uri, $item->icono);
|
|
});
|
|
array_walk($links->consulta, function(&$item) {
|
|
$item = new Link($item->texto, $item->uri);
|
|
});
|
|
$aviso = $manager->folder('data')->load('aviso.yml');
|
|
$transparencia = $manager->folder('data')->load('transparencia.yml')->activo;
|
|
return $view->render($response, 'home', compact('banner', 'aviso', 'links', 'transparencia'));
|
|
}
|
|
}
|
|
|
|
class Documento {
|
|
protected $icono;
|
|
protected $texto;
|
|
protected $uri;
|
|
|
|
public function __construct(Container $container, string $nombre, string $uri = '', string $icono = '') {
|
|
$this->icono = $icono;
|
|
if ($icono == '') {
|
|
$this->icono = implode('/', [$container->get('urls.images'), $nombre . '.png']);
|
|
}
|
|
$this->texto = $nombre;
|
|
$this->uri = $uri;
|
|
if ($uri == '') {
|
|
$this->uri = implode('/', [$container->get('urls.base'), 'documentos', strtolower($nombre)]);
|
|
}
|
|
}
|
|
public function show(): string {
|
|
return '<a href="' . $this->uri . '"><i class="large ' . $this->icono . ' icon"></i> ' . $this->texto . '</a>';
|
|
}
|
|
}
|
|
class Link {
|
|
protected $uri;
|
|
protected $texto;
|
|
|
|
public function __construct(string $texto, string $uri) {
|
|
$this->texto = $texto;
|
|
$this->uri = $uri;
|
|
}
|
|
public function show(): string {
|
|
return '<a href="' . $this->uri . '">' . $this->texto . '</a>';
|
|
}
|
|
}
|