summaryrefslogtreecommitdiff
path: root/src/Support/RouteLoader.php
blob: ba124c580af7692ff6c09b0ddcaf08e6db94a310 (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\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)
    );
  }
}