-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Create different operation names for each Entity with WebResponse.
- Loading branch information
roadiz-ci
committed
Feb 12, 2024
1 parent
deef9ce
commit 5ada723
Showing
3 changed files
with
88 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RZ\Roadiz\CoreBundle\NodeType; | ||
|
||
use Symfony\Component\String\UnicodeString; | ||
|
||
final class ApiResourceOperationNameGenerator | ||
{ | ||
public function generate(string $resourceClass, string $operation): string | ||
{ | ||
return sprintf( | ||
'%s_%s', | ||
(new UnicodeString($resourceClass)) | ||
->afterLast('\\') | ||
->trimPrefix('NS') | ||
->lower() | ||
->toString(), | ||
$operation | ||
); | ||
} | ||
|
||
public function generateGetByPath(string $resourceClass): string | ||
{ | ||
return self::generate($resourceClass, 'get_by_path'); | ||
} | ||
} |