Skip to content
This repository was archived by the owner on Jun 19, 2022. It is now read-only.

Commit e8809f2

Browse files
committed
update skeleton template
1 parent d350559 commit e8809f2

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/Resources/skeleton/crud/Controller.tpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(Manager $manager, AutoMapperInterface $mapper)
4040
<?php if (isset($repository_full_class_name)): ?>
4141
public function collection(Request $request, <?= $repository_class_name ?> $<?= $repository_var ?>, PaginatorInterface $pagination): Response
4242
{
43-
$data = $pagination->paginate($<?= $repository_var ?>->findByQB(), <?= $transformer_class_name ?>::class);
43+
$data = $pagination->paginate($<?= $repository_var ?>->createQueryBuilder('qb'), <?= $transformer_class_name ?>::class);
4444

4545
return $this->json($this->fractal($request)->createData($data)->toArray());
4646
}

src/Resources/skeleton/dto/Mapper.tpl.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use AutoMapperPlus\AutoMapperPlusBundle\AutoMapperConfiguratorInterface;
88
use AutoMapperPlus\Configuration\AutoMapperConfigInterface;
99
use AutoMapperPlus\CustomMapper\CustomMapper;
10+
use Doctrine\ORM\EntityManagerInterface;
1011

1112
class <?= $class_name ?> extends CustomMapper implements AutoMapperConfiguratorInterface
1213
{
@@ -24,6 +25,13 @@ class <?= $class_name ?> extends CustomMapper implements AutoMapperConfiguratorI
2425
*/
2526
private $destination;
2627

28+
//private $entityManager;
29+
30+
//public function __construct(EntityManagerInterface $entityManager)
31+
//{
32+
// $this->entityManager = $entityManager;
33+
//}
34+
2735
public function configure(AutoMapperConfigInterface $config): void
2836
{
2937
$config->registerMapping(<?= $dto_class_name ?>::class, <?= $entity_class_name ?>::class)

src/Resources/skeleton/transformer/Transformer.tpl.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use League\Fractal\TransformerAbstract;
66
use <?= $entity_full_class_name ?>;
7+
use League\Fractal\Resource\Collection;
8+
use League\Fractal\Resource\Item;
79

810
/**
911
* Transformer are use to decorate your custom output data before serialize it to JSON.
@@ -31,22 +33,22 @@ class <?= $class_name ?> extends TransformerAbstract
3133
* Add whatever properties & methods you need to hold the
3234
* data for this message class.
3335
*/
34-
public function transform(<?= $entity_class_name ?> $<?= $entity_variable_name ?>): ?array
36+
public function transform(?<?= $entity_class_name ?> $<?= $entity_variable_name ?>): ?array
3537
{
3638
// Decorate your return data in array form.
37-
return [
39+
return $<?= $entity_variable_name ?> ? [
3840
'id' => $<?= $entity_variable_name ?>->getId(),
39-
];
41+
] : $this->null();
4042
}
4143

4244
/**
4345
* Write this function if you have declare something in $availableIncludes or $defaultIncludes
4446
*
45-
* Example: If you include 'user', the method name and its parameter will be 'public function includeUser(User $user)'
47+
* Example: If you include 'user', the method name and its parameter will be 'public function includeUser()'
4648
*/
47-
// public function includeExample(/** entity class */)
49+
// public function includeExample(?<?= $entity_class_name ?> $<?= $entity_variable_name ?>)
4850
// {
49-
// return $this->item(/** entity class */, /** transformer class */);
51+
// return $<?= $entity_variable_name ?>->getterMethod() ? $this->item($<?= $entity_variable_name ?>->getterMethod(), /** transformer class */) : $this->null();
5052
// }
5153

5254
}

0 commit comments

Comments
 (0)