Skip to content

Resolve: Methods naming for non crud actions #144 #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix issue in generated url rule config
  • Loading branch information
SOHELAHMED7 committed Jul 10, 2024
commit 7799c8e3777dfdf6a87db6c34c4a2fc836f89307
8 changes: 7 additions & 1 deletion src/generator/default/urls.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<?php

use yii\helpers\VarDumper;

?>
<?= '<?php' ?>

/**
* OpenAPI UrlRules
*
* This file is auto generated.
*/
<?php $rules = \yii\helpers\VarDumper::export($urls);?>
<?php /** @var array $urls */
$rules = VarDumper::export($urls); ?>
return <?= str_replace('\\\\', '\\', $rules); ?>;
4 changes: 2 additions & 2 deletions src/lib/generators/RestActionGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ protected function prepareAction(string $method, Operation $operation, RouteData
} else {
$controllerId = $routeData->controller;
}
$action = ucfirst($routeData->action);
$action = Inflector::camel2id($routeData->action);
return Yii::createObject(RestAction::class, [
[
'id' => trim("$actionType$action", '-'),
'id' => trim("$actionType-$action", '-'),
'controllerId' => $controllerId,
'urlPath' => $routeData->path,
'requestMethod' => strtoupper($method),
Expand Down
4 changes: 2 additions & 2 deletions src/lib/items/RestAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public function getRoute():string
{
if ($this->prefix && !empty($this->prefixSettings)) {
$prefix = $this->prefixSettings['module'] ?? $this->prefix;
return trim($prefix, '/').'/'.$this->controllerId.'/'.$this->id;
return trim($prefix, '/') . '/' . $this->controllerId . '/' . $this->id;
}
return $this->controllerId.'/'.$this->id;
return $this->controllerId . '/' . $this->id;
}

public function getOptionsRoute():string
Expand Down
Loading