summaryrefslogtreecommitdiff
path: root/src/http/Support/RouteLoader.php
blob: b0e74cb6c18c950748f450a880ca23fcd1c73636 (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
<?php

namespace App\http\Support;

use Symfony\Component\Routing\Loader\AnnotationClassLoader;
use Symfony\Component\Routing\Route;

class RouteLoader extends AnnotationClassLoader
{
  protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annotation) {
    $route->setDefault('_', compact('class', 'method', 'annotation'));
  }

  protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method)
  {
    $name = parent::getDefaultRouteName($class, $method);

    return str_replace(
      '_',
      '.',
      str_replace('app_controller_', '', $name)
    );
  }
}