Skip to content

Commit efa1bd1

Browse files
committed
Issue #28: Fixed template naming pattern
Signed-off-by: alexmerlin <[email protected]>
1 parent 2bfc43f commit efa1bd1

11 files changed

+47
-47
lines changed

src/Type/Handler.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function create(string $name): File
7979
$template = $this->fileSystem
8080
->templateFile(
8181
$entity->getComponent()->toKebabCase(),
82-
sprintf('%s-list', $entity->getComponent()->toKebabCase())
82+
sprintf('list-%s', $entity->getComponent()->toKebabCase())
8383
);
8484
if (! $template->exists()) {
8585
$template->create(sprintf('List %s template', $plural));
@@ -93,7 +93,7 @@ public function create(string $name): File
9393
$template = $this->fileSystem
9494
->templateFile(
9595
$entity->getComponent()->toKebabCase(),
96-
sprintf('%s-view', $entity->getComponent()->toKebabCase())
96+
sprintf('view-%s', $entity->getComponent()->toKebabCase())
9797
);
9898
if (! $template->exists()) {
9999
$template->create(sprintf('View %s template', $plural));
@@ -110,7 +110,7 @@ public function create(string $name): File
110110
$template = $this->fileSystem
111111
->templateFile(
112112
$entity->getComponent()->toKebabCase(),
113-
sprintf('%s-create-form', $entity->getComponent()->toKebabCase())
113+
sprintf('create-%s-form', $entity->getComponent()->toKebabCase())
114114
);
115115
if (! $template->exists()) {
116116
$template->create(sprintf('Create %s template', $plural));
@@ -128,7 +128,7 @@ public function create(string $name): File
128128
$template = $this->fileSystem
129129
->templateFile(
130130
$entity->getComponent()->toKebabCase(),
131-
sprintf('%s-delete-form', $entity->getComponent()->toKebabCase())
131+
sprintf('delete-%s-form', $entity->getComponent()->toKebabCase())
132132
);
133133
if (! $template->exists()) {
134134
$template->create(sprintf('Delete %s template', $plural));
@@ -145,7 +145,7 @@ public function create(string $name): File
145145
$template = $this->fileSystem
146146
->templateFile(
147147
$entity->getComponent()->toKebabCase(),
148-
sprintf('%s-edit-form', $entity->getComponent()->toKebabCase())
148+
sprintf('edit-%s-form', $entity->getComponent()->toKebabCase())
149149
);
150150
if (! $template->exists()) {
151151
$template->create(sprintf('Edit %s template', $plural));

src/Type/Handler/GetCreateResourceHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function render(Component $handler, Component $entity, Component $form):
8989
->setAttribute('action', \$this->router->generateUri('{$entity->toKebabCase()}::{$entity->toKebabCase()}-create'));
9090
9191
return new HtmlResponse(
92-
\$this->template->render('{$entity->toKebabCase()}::{$entity->toKebabCase()}-create-form', [
92+
\$this->template->render('{$entity->toKebabCase()}::create-{$entity->toKebabCase()}-form', [
9393
'form' => \$this->{$form->toCamelCase()}->prepare(),
9494
])
9595
);

src/Type/Handler/GetDeleteResourceHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function render(Component $handler, Component $entity, Component $form, C
116116
);
117117
118118
return new HtmlResponse(
119-
\$this->template->render('{$entity->toKebabCase()}::{$entity->toKebabCase()}-delete-form', [
119+
\$this->template->render('{$entity->toKebabCase()}::delete-{$entity->toKebabCase()}-form', [
120120
'form' => \$this->{$form->toCamelCase()}->prepare(),
121121
'{$entity->toKebabCase()}' => {$entity->getVariable()},
122122
])

src/Type/Handler/GetEditResourceHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function render(Component $handler, Component $entity, Component $form, C
118118
->bind({$entity->getVariable()});
119119
120120
return new HtmlResponse(
121-
\$this->template->render('{$entity->toKebabCase()}::{$entity->toKebabCase()}-edit-form', [
121+
\$this->template->render('{$entity->toKebabCase()}::edit-{$entity->toKebabCase()}-form', [
122122
'form' => \$this->{$form->toCamelCase()}->prepare(),
123123
'{$entity->toKebabCase()}' => {$entity->getVariable()},
124124
])

src/Type/Handler/GetListResourceHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function render(Component $handler, Component $entity, Component $service
8686
)
8787
->setBody(<<<BODY
8888
return new HtmlResponse(
89-
\$this->template->render('{$entity->toKebabCase()}::{$entity->toKebabCase()}-list', [
89+
\$this->template->render('{$entity->toKebabCase()}::list-{$entity->toKebabCase()}', [
9090
'pagination' => \$this->{$serviceInterface->toCamelCase(true)}->{$entity->getCollectionMethodName()}(\$request->getQueryParams()),
9191
])
9292
);

src/Type/Handler/GetViewResourceHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function render(Component $handler, Component $entity, Component $service
102102
}
103103
104104
return new HtmlResponse(
105-
\$this->template->render('{$entity->toKebabCase()}::{$entity->toKebabCase()}-view', [
105+
\$this->template->render('{$entity->toKebabCase()}::view-{$entity->toKebabCase()}', [
106106
'{$entity->toCamelCase()}' => {$entity->getVariable()},
107107
])
108108
);

src/Type/Handler/PostCreateResourceHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ public function render(Component $handler, Component $entity, Component $form, C
124124
}
125125
126126
return new HtmlResponse(
127-
\$this->template->render('{$entity->toKebabCase()}::{$entity->toKebabCase()}-create-form', [
127+
\$this->template->render('{$entity->toKebabCase()}::create-{$entity->toKebabCase()}-form', [
128128
'form' => \$this->{$form->toCamelCase()}->prepare(),
129129
]),
130130
StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY
131131
);
132132
} catch (ConflictException \$exception) {
133133
return new HtmlResponse(
134-
\$this->template->render('{$entity->toKebabCase()}::{$entity->toKebabCase()}-create-form', [
134+
\$this->template->render('{$entity->toKebabCase()}::create-{$entity->toKebabCase()}-form', [
135135
'form' => \$this->{$form->toCamelCase()}->prepare(),
136136
'messages' => [
137137
'error' => \$exception->getMessage(),
@@ -148,7 +148,7 @@ public function render(Component $handler, Component $entity, Component $form, C
148148
]);
149149
150150
return new HtmlResponse(
151-
\$this->template->render('{$entity->toKebabCase()}::{$entity->toKebabCase()}-create-form', [
151+
\$this->template->render('{$entity->toKebabCase()}::create-{$entity->toKebabCase()}-form', [
152152
'form' => \$this->{$form->toCamelCase()}->prepare(),
153153
'messages' => [
154154
'error' => Message::AN_ERROR_OCCURRED,

src/Type/Handler/PostDeleteResourceHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function render(Component $handler, Component $entity, Component $form, C
133133
}
134134
135135
return new HtmlResponse(
136-
\$this->template->render('{$entity->toKebabCase()}::{$entity->toKebabCase()}-delete-form', [
136+
\$this->template->render('{$entity->toKebabCase()}::delete-{$entity->toKebabCase()}-form', [
137137
'form' => \$this->{$form->toCamelCase()}->prepare(),
138138
'{$entity->toCamelCase()}' => {$entity->getVariable()},
139139
]),

src/Type/Handler/PostEditResourceHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ public function render(Component $handler, Component $entity, Component $form, C
137137
}
138138
139139
return new HtmlResponse(
140-
\$this->template->render('{$entity->toKebabCase()}::{$entity->toKebabCase()}-edit-form', [
140+
\$this->template->render('{$entity->toKebabCase()}::edit-{$entity->toKebabCase()}-form', [
141141
'form' => \$this->{$form->toCamelCase()}->prepare(),
142142
'{$entity->toCamelCase()}' => {$entity->getVariable()},
143143
]),
144144
StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY
145145
);
146146
} catch (BadRequestException | ConflictException | NotFoundException \$exception) {
147147
return new HtmlResponse(
148-
\$this->template->render('{$entity->toKebabCase()}::{$entity->toKebabCase()}-edit-form', [
148+
\$this->template->render('{$entity->toKebabCase()}::edit-{$entity->toKebabCase()}-form', [
149149
'form' => \$this->{$form->toCamelCase()}->prepare(),
150150
'{$entity->toCamelCase()}' => {$entity->getVariable()},
151151
'messages' => [

test/Type/HandlerTest.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function testCallToInvokeWillCreateOnlyListResourceHandler(): void
197197
$this->assertDirectoryExists($templateDir->getPath());
198198
$this->assertTrue($templateDir->exists());
199199

200-
$templateFile = $this->fileSystem->templateFile($entity->getComponent()->toKebabCase(), 'book-store-list');
200+
$templateFile = $this->fileSystem->templateFile($entity->getComponent()->toKebabCase(), 'list-book-store');
201201
$this->assertFileExists($templateFile->getPath());
202202
$this->assertTrue($templateFile->exists());
203203

@@ -289,7 +289,7 @@ public function testCallToInvokeWillCreateOnlyViewResourceHandler(): void
289289
$this->assertDirectoryExists($templateDir->getPath());
290290
$this->assertTrue($templateDir->exists());
291291

292-
$templateFile = $this->fileSystem->templateFile($entity->getComponent()->toKebabCase(), 'book-store-view');
292+
$templateFile = $this->fileSystem->templateFile($entity->getComponent()->toKebabCase(), 'view-book-store');
293293
$this->assertFileExists($templateFile->getPath());
294294
$this->assertTrue($templateFile->exists());
295295

@@ -384,7 +384,7 @@ public function testCallToInvokeWillCreateOnlyCreateResourceHandler(): void
384384

385385
$templateFile = $this->fileSystem->templateFile(
386386
$entity->getComponent()->toKebabCase(),
387-
'book-store-create-form'
387+
'create-book-store-form'
388388
);
389389
$this->assertFileExists($templateFile->getPath());
390390
$this->assertTrue($templateFile->exists());
@@ -480,7 +480,7 @@ public function testCallToInvokeWillCreateOnlyDeleteResourceHandler(): void
480480

481481
$templateFile = $this->fileSystem->templateFile(
482482
$entity->getComponent()->toKebabCase(),
483-
'book-store-delete-form'
483+
'delete-book-store-form'
484484
);
485485
$this->assertFileExists($templateFile->getPath());
486486
$this->assertTrue($templateFile->exists());
@@ -576,7 +576,7 @@ public function testCallToInvokeWillCreateOnlyEditResourceHandler(): void
576576

577577
$templateFile = $this->fileSystem->templateFile(
578578
$entity->getComponent()->toKebabCase(),
579-
'book-store-edit-form'
579+
'edit-book-store-form'
580580
);
581581
$this->assertFileExists($templateFile->getPath());
582582
$this->assertTrue($templateFile->exists());
@@ -669,7 +669,7 @@ public function testCallToCreateWillCreateOnlyListResourceHandler(): void
669669
$this->assertDirectoryExists($templateDir->getPath());
670670
$this->assertTrue($templateDir->exists());
671671

672-
$templateFile = $this->fileSystem->templateFile($entity->getComponent()->toKebabCase(), 'book-store-list');
672+
$templateFile = $this->fileSystem->templateFile($entity->getComponent()->toKebabCase(), 'list-book-store');
673673
$this->assertFileExists($templateFile->getPath());
674674
$this->assertTrue($templateFile->exists());
675675

@@ -761,7 +761,7 @@ public function testCallToCreateWillCreateOnlyViewResourceHandler(): void
761761
$this->assertDirectoryExists($templateDir->getPath());
762762
$this->assertTrue($templateDir->exists());
763763

764-
$templateFile = $this->fileSystem->templateFile($entity->getComponent()->toKebabCase(), 'book-store-view');
764+
$templateFile = $this->fileSystem->templateFile($entity->getComponent()->toKebabCase(), 'view-book-store');
765765
$this->assertFileExists($templateFile->getPath());
766766
$this->assertTrue($templateFile->exists());
767767

@@ -856,7 +856,7 @@ public function testCallToCreateWillCreateOnlyCreateResourceHandler(): void
856856

857857
$templateFile = $this->fileSystem->templateFile(
858858
$entity->getComponent()->toKebabCase(),
859-
'book-store-create-form'
859+
'create-book-store-form'
860860
);
861861
$this->assertFileExists($templateFile->getPath());
862862
$this->assertTrue($templateFile->exists());
@@ -952,7 +952,7 @@ public function testCallToCreateWillCreateOnlyDeleteResourceHandler(): void
952952

953953
$templateFile = $this->fileSystem->templateFile(
954954
$entity->getComponent()->toKebabCase(),
955-
'book-store-delete-form'
955+
'delete-book-store-form'
956956
);
957957
$this->assertFileExists($templateFile->getPath());
958958
$this->assertTrue($templateFile->exists());
@@ -1048,7 +1048,7 @@ public function testCallToCreateWillCreateOnlyEditResourceHandler(): void
10481048

10491049
$templateFile = $this->fileSystem->templateFile(
10501050
$entity->getComponent()->toKebabCase(),
1051-
'book-store-edit-form'
1051+
'edit-book-store-form'
10521052
);
10531053
$this->assertFileExists($templateFile->getPath());
10541054
$this->assertTrue($templateFile->exists());
@@ -1097,7 +1097,7 @@ public function handle(
10971097
ServerRequestInterface \$request,
10981098
): ResponseInterface {
10991099
return new HtmlResponse(
1100-
\$this->template->render('book-store::book-store-list', [
1100+
\$this->template->render('book-store::list-book-store', [
11011101
'pagination' => \$this->bookStoreService->getBookStores(\$request->getQueryParams()),
11021102
])
11031103
);
@@ -1161,7 +1161,7 @@ public function handle(
11611161
}
11621162
11631163
return new HtmlResponse(
1164-
\$this->template->render('book-store::book-store-view', [
1164+
\$this->template->render('book-store::view-book-store', [
11651165
'bookStore' => \$bookStore,
11661166
])
11671167
);
@@ -1217,7 +1217,7 @@ public function handle(
12171217
->setAttribute('action', \$this->router->generateUri('book-store::book-store-create'));
12181218
12191219
return new HtmlResponse(
1220-
\$this->template->render('book-store::book-store-create-form', [
1220+
\$this->template->render('book-store::create-book-store-form', [
12211221
'form' => \$this->createBookStoreForm->prepare(),
12221222
])
12231223
);
@@ -1299,14 +1299,14 @@ public function handle(
12991299
}
13001300
13011301
return new HtmlResponse(
1302-
\$this->template->render('book-store::book-store-create-form', [
1302+
\$this->template->render('book-store::create-book-store-form', [
13031303
'form' => \$this->createBookStoreForm->prepare(),
13041304
]),
13051305
StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY
13061306
);
13071307
} catch (ConflictException \$exception) {
13081308
return new HtmlResponse(
1309-
\$this->template->render('book-store::book-store-create-form', [
1309+
\$this->template->render('book-store::create-book-store-form', [
13101310
'form' => \$this->createBookStoreForm->prepare(),
13111311
'messages' => [
13121312
'error' => \$exception->getMessage(),
@@ -1323,7 +1323,7 @@ public function handle(
13231323
]);
13241324
13251325
return new HtmlResponse(
1326-
\$this->template->render('book-store::book-store-create-form', [
1326+
\$this->template->render('book-store::create-book-store-form', [
13271327
'form' => \$this->createBookStoreForm->prepare(),
13281328
'messages' => [
13291329
'error' => Message::AN_ERROR_OCCURRED,
@@ -1404,7 +1404,7 @@ public function handle(
14041404
);
14051405
14061406
return new HtmlResponse(
1407-
\$this->template->render('book-store::book-store-delete-form', [
1407+
\$this->template->render('book-store::delete-book-store-form', [
14081408
'form' => \$this->deleteBookStoreForm->prepare(),
14091409
'book-store' => \$bookStore,
14101410
])
@@ -1496,7 +1496,7 @@ public function handle(
14961496
}
14971497
14981498
return new HtmlResponse(
1499-
\$this->template->render('book-store::book-store-delete-form', [
1499+
\$this->template->render('book-store::delete-book-store-form', [
15001500
'form' => \$this->deleteBookStoreForm->prepare(),
15011501
'bookStore' => \$bookStore,
15021502
]),
@@ -1588,7 +1588,7 @@ public function handle(
15881588
->bind(\$bookStore);
15891589
15901590
return new HtmlResponse(
1591-
\$this->template->render('book-store::book-store-edit-form', [
1591+
\$this->template->render('book-store::edit-book-store-form', [
15921592
'form' => \$this->editBookStoreForm->prepare(),
15931593
'book-store' => \$bookStore,
15941594
])
@@ -1686,15 +1686,15 @@ public function handle(
16861686
}
16871687
16881688
return new HtmlResponse(
1689-
\$this->template->render('book-store::book-store-edit-form', [
1689+
\$this->template->render('book-store::edit-book-store-form', [
16901690
'form' => \$this->editBookStoreForm->prepare(),
16911691
'bookStore' => \$bookStore,
16921692
]),
16931693
StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY
16941694
);
16951695
} catch (BadRequestException | ConflictException | NotFoundException \$exception) {
16961696
return new HtmlResponse(
1697-
\$this->template->render('book-store::book-store-edit-form', [
1697+
\$this->template->render('book-store::edit-book-store-form', [
16981698
'form' => \$this->editBookStoreForm->prepare(),
16991699
'bookStore' => \$bookStore,
17001700
'messages' => [

0 commit comments

Comments
 (0)