summaryrefslogtreecommitdiff
path: root/src/Router/Route.php
blob: ee9637bf7226635baac1beab453e9aa565ade652 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php

namespace ERPHP\Router;

use Symfony\Component\Routing\Route as SymfonyRoute;

class Route extends SymfonyRoute
{
  public function __construct(
    string $path,
    callable $action,
    private string $name = "",
    array $defaults = [],
    array $requirements = [],
    array $options = [],
    ?string $host = '',
    string|array $schemes = [],
    string|array $methods = [],
    ?string $condition = '',
  )
  {
    if (empty($name)) {
      $this->name = $path;
    }

    $defaults = array_merge([
      "_" => [
        "action" => $action,
      ],
    ], $defaults);

    parent::__construct($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition);
  }

  public function getName(): string
  {
    return $this->name;
  }
}