<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
/**
* 作用说明:渲染默认入口模板,作为未命中具体接口时的基础页面入口? */
class DefaultController extends AbstractController
{
private string $publicBaseUrl;
public function __construct(string $publicBaseUrl)
{
$this->publicBaseUrl = rtrim($publicBaseUrl, '/');
}
public function index(){
$indexFile = $this->getParameter('kernel.project_dir') . '/public/index.html';
if (is_file($indexFile)) {
return new Response((string) file_get_contents($indexFile), 200, ['Content-Type' => 'text/html; charset=UTF-8']);
}
throw $this->createNotFoundException('Frontend entry file public/index.html was not built.');
}
public function paySession(string $payToken): Response
{
return $this->index();
}
private function absolutePublicUrl(string $path): string
{
return $this->publicBaseUrl !== '' ? $this->publicBaseUrl . $path : $path;
}
}