WIP: feature_paste #1
|
@ -27,7 +27,7 @@ class PasteController extends AbstractController
|
|||
$pasteData->ip = $request->getClientIp();
|
||||
skobkin marked this conversation as resolved
Outdated
|
||||
|
||||
$paste = Paste::fromFormData($pasteData);
|
||||
skobkin marked this conversation as resolved
Outdated
skobkin
commented
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
skobkin
commented
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'));
|
||||
}
|
||||
skobkin marked this conversation as resolved
Outdated
skobkin
commented
I still suggest to make I still suggest to make `Paste::fromFormData()`.
|
||||
|
|
|
@ -14,10 +14,13 @@ class PasteRepository extends ServiceEntityRepository
|
|||
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
skobkin
commented
Do not forget to use code formatting. It'd surrounded Do not forget to use code formatting. It'd surrounded `=` with spaces for you.
|
||||
{
|
||||
$entityManager = $this->getEntityManager();
|
||||
$entityManager->persist($paste);
|
||||
$entityManager->flush();
|
||||
|
||||
skobkin marked this conversation as resolved
Outdated
skobkin
commented
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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue
Do you need IP in
PasteData
?