36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
namespace ProVM\NotariaRaby\Common\Controller\Web\Admin;
|
|
|
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
|
use Psr\Http\Message\ResponseInterface as Response;
|
|
use ProVM\Common\Service\Filemanager;
|
|
|
|
class Transparencia {
|
|
public function do_edit(Request $request, Response $response, Filemanager $filemanager): Response {
|
|
$post = $request->getParsedBody();
|
|
$filename = 'transparencia.yml';
|
|
$transparencia = $filemanager->folder('data')->load($filename);
|
|
if (!$transparencia) {
|
|
$transparencia = (object) [
|
|
'descripcion' => '',
|
|
'funciones' => '',
|
|
'activo' => false
|
|
];
|
|
}
|
|
if (isset($post['activo'])) {
|
|
$transparencia->activo = json_decode($post['activo']);
|
|
}
|
|
$status = $filemanager->folder('data')->save($filename, $transparencia);
|
|
|
|
$output = [
|
|
'informacion' => $post,
|
|
'editado' => $transparencia,
|
|
'estado' => ($status !== false) ? 'ok' : 'error'
|
|
];
|
|
$response->getBody()->write(json_encode($output));
|
|
return $response
|
|
->withHeader('Content-Type', 'application/json')
|
|
->withStatus(201);
|
|
}
|
|
}
|