Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
Merge 9f72b45 into 7671e51
Browse files Browse the repository at this point in the history
  • Loading branch information
Harrison Heck committed Mar 7, 2018
2 parents 7671e51 + 9f72b45 commit dac8b6c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Routing/OpenApiRouteLoader.php
Expand Up @@ -199,9 +199,12 @@ private function createRouteId(string $resource, string $path, string $controlle
{
$controllerSegments = explode(':', $controllerKey);

$operationName = 'action';
if (count($controllerSegments) === 2) {
list(, $operationName) = $controllerSegments;
} else {
$className = basename(str_replace('\\', '/', $controllerKey));
// Convert class name to snake_case
$operationName = strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $className));
}

$fileName = pathinfo($resource, PATHINFO_FILENAME);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Routing/OpenApiRouteLoaderTest.php
Expand Up @@ -239,7 +239,7 @@ public function canUseOperationIdAsInvokableControllerKey()

$routes = $this->loader->load(self::DOCUMENT_PATH);

$actual = $routes->get('customname.path.a.action');
$actual = $routes->get('customname.path.a.invokable_controller');
$this->assertNotNull($actual);
$this->assertSame($expected, $actual->getDefault('_controller'));
}
Expand Down

0 comments on commit dac8b6c

Please sign in to comment.