Разделение по отдельным репозиториям

This commit is contained in:
2025-03-03 16:31:32 +08:00
commit a1f5154ce8
44 changed files with 4362 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace App\Controllers;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Random\RandomException;
/**
*
*/
class ApiController extends BasicController
{
/**
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @return ResponseInterface
* @throws RandomException
*/
public function json(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
{
$code = $request->getAttributes()['code'];
$playlist = $this->getPlaylist($code, true);
$playlist->fetchContent();
$playlist->parse();
$json = json_encode($playlist->toArray(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$response->getBody()->write($json);
return $response
->withHeader('Content-Type', 'application/json')
->withHeader('Content-Length', strlen($json));
}
}