Skip to content

Commit ef2536a

Browse files
committed
Generate Module.php file for urlPrefixes.module config - WIP
1 parent 4df4cea commit ef2536a

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

src/lib/items/RouteData.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,14 @@ protected function detectUrlPattern():void
322322
$this->unprefixedPath = '/' . trim(str_replace($prefix, '', $this->path), '/');
323323
$this->parts = explode('/', trim($this->unprefixedPath, '/'));
324324
$this->prefixSettings = is_array($rule) ? $rule : [];
325+
326+
$modulesPath = [];
327+
if(isset($rule['module'])) {
328+
// var_dump($rule['module'], $prefix);
329+
$modulesPath[$modulesPath] = ['path' => '@app/TODO' , 'namespace' => 'app\\TODO' . ];
330+
331+
}
332+
$this->moduleList = [...$this->moduleList, ...$modulesPath];
325333
}
326334
foreach (self::$patternMap as $type => $pattern) {
327335
if (preg_match($pattern, $this->unprefixedPath, $matches)) {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
return [
4+
'openApiPath' => '@specs/issue_fix/14_module_config_in_url_prefixes/index.yml',
5+
'generateUrls' => true,
6+
'generateModels' => false,
7+
// 'useJsonApi' => true, // TODO for FractalAction
8+
'excludeModels' => [
9+
'Error',
10+
],
11+
'generateControllers' => true,
12+
'generateMigrations' => false,
13+
'generateModelFaker' => false,
14+
'urlPrefixes' => [
15+
'hi' => ['module' => 'greet', 'namespace' => 'app\greet'],
16+
]
17+
];
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
openapi: "3.0.0"
2+
info:
3+
version: 1.0.0
4+
title: Issue14Test 14_module_config_in_url_prefixes \#14
5+
6+
paths:
7+
/hi:
8+
get:
9+
summary: List
10+
operationId: list
11+
responses:
12+
'200':
13+
description: The information

tests/unit/issues/Issue14Test.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,17 @@ public function testNestedModuleInXRoute()
2121
]);
2222
$this->checkFiles($actualFiles, $expectedFiles);
2323
}
24+
25+
public function testModuleConfigInUrlPrefixes()
26+
{
27+
$testFile = Yii::getAlias("@specs/issue_fix/14_module_config_in_url_prefixes/index.php");
28+
$this->runGenerator($testFile);
29+
// $actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
30+
// 'recursive' => true,
31+
// ]);
32+
// $expectedFiles = FileHelper::findFiles(Yii::getAlias("@specs/issue_fix/14_nested_module_in_x_route/mysql"), [
33+
// 'recursive' => true,
34+
// ]);
35+
// $this->checkFiles($actualFiles, $expectedFiles);
36+
}
2437
}

0 commit comments

Comments
 (0)