summaryrefslogtreecommitdiff
path: root/src/http/Support/RouteLoader.php
blob: d11011ca1e3ad1e6a9bffd8037f059e1b71989d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php

namespace App\http\Support;

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

class RouteLoader extends AttributeClassLoader
{
  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);

    $name = preg_replace('/app_\w+_controller_/', '', $name);
    $name = str_replace('_', '.', $name);

    return $name;
  }
}