[ActionFactory] Allow camel-case action names (#3044)

Dash symbol is used to convert dash-seperated string to camel-cased string
This commit is contained in:
Eugene Molotov 2022-09-20 21:17:57 +05:00 committed by GitHub
parent 2db523a37a
commit 3d9fead463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -26,7 +26,8 @@ class ActionFactory
*/ */
public function create(string $name): ActionInterface public function create(string $name): ActionInterface
{ {
$name = ucfirst(strtolower($name)) . 'Action'; $name = strtolower($name) . 'Action';
$name = implode(array_map('ucfirst', explode('-', $name)));
$filePath = $this->folder . $name . '.php'; $filePath = $this->folder . $name . '.php';
if (!file_exists($filePath)) { if (!file_exists($filePath)) {
throw new \Exception('Invalid action'); throw new \Exception('Invalid action');