WIP: feature_paste #1

Draft
Miroslavsckaya wants to merge 24 commits from feature_paste into master
2 changed files with 6 additions and 3 deletions
Showing only changes of commit 8bceb97550 - Show all commits

View file

@ -27,7 +27,7 @@ class PasteController extends AbstractController
$pasteData->ip = $request->getClientIp(); $pasteData->ip = $request->getClientIp();
skobkin marked this conversation as resolved Outdated

Do you need IP in PasteData?

Do you need IP in `PasteData`?
$paste = Paste::fromFormData($pasteData); $paste = Paste::fromFormData($pasteData);
skobkin marked this conversation as resolved Outdated

Do we need double quotes here?

By the way, we can also do that in the constructor.

Do we need double quotes here? By the way, we can also do that in the constructor.
skobkin marked this conversation as resolved Outdated

This still could be done in the entity itself.

This still could be done in the entity itself.
$pasteRepository->save($paste); $pasteRepository->save($paste, true);
return $this->redirectToRoute($request->attributes->get('_route')); return $this->redirectToRoute($request->attributes->get('_route'));
} }
skobkin marked this conversation as resolved Outdated

I still suggest to make Paste::fromFormData().

I still suggest to make `Paste::fromFormData()`.

View file

@ -14,10 +14,13 @@ class PasteRepository extends ServiceEntityRepository
parent::__construct($registry, Paste::class); parent::__construct($registry, Paste::class);
} }
public function save(Paste $paste): void public function save(Paste $paste, bool $flush=false): void
skobkin marked this conversation as resolved Outdated

Do not forget to use code formatting. It'd surrounded = with spaces for you.

Do not forget to use code formatting. It'd surrounded `=` with spaces for you.
{ {
$entityManager = $this->getEntityManager(); $entityManager = $this->getEntityManager();
$entityManager->persist($paste); $entityManager->persist($paste);
skobkin marked this conversation as resolved Outdated

You shouldn't do flush here by default. Only in certain cases if needed.

You shouldn't do flush here by default. Only in certain cases if needed.
if ($flush) {
$entityManager->flush(); $entityManager->flush();
} }
} }
}