web-base/Core/Objects/Router/StaticRoute.class.php

30 lines
695 B
PHP
Raw Normal View History

2022-06-01 09:47:31 +02:00
<?php
2022-11-18 18:06:46 +01:00
namespace Core\Objects\Router;
2022-06-01 09:47:31 +02:00
2024-03-28 11:56:17 +01:00
use Core\Objects\DatabaseEntity\Attribute\Transient;
2022-11-27 12:33:27 +01:00
use Core\Objects\DatabaseEntity\Route;
class StaticRoute extends Route {
2022-06-01 09:47:31 +02:00
2024-03-28 11:56:17 +01:00
#[Transient]
2022-06-01 09:47:31 +02:00
private string $data;
2024-03-28 11:56:17 +01:00
#[Transient]
2022-06-01 09:47:31 +02:00
private int $code;
public function __construct(string $pattern, bool $exact, string $data, int $code = 200) {
parent::__construct("static", $pattern, "", $exact);
2022-06-01 09:47:31 +02:00
$this->data = $data;
$this->code = $code;
}
public function call(Router $router, array $params): string {
http_response_code($this->code);
return $this->data;
}
protected function getArgs(): array {
return array_merge(parent::getArgs(), [$this->data, $this->code]);
}
}