Skip to content
This repository was archived by the owner on May 27, 2023. It is now read-only.

Commit 902599d

Browse files
committed
remove deprecated usage of getDoctrine() method
1 parent af114fb commit 902599d

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

Controller/ProfileController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Zikula\ProfileModule\Controller;
1515

16+
use Doctrine\Persistence\ManagerRegistry;
1617
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
1718
use Symfony\Component\HttpFoundation\File\UploadedFile;
1819
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -64,6 +65,7 @@ public function display(
6465
*/
6566
public function edit(
6667
Request $request,
68+
ManagerRegistry $doctrine,
6769
CurrentUserApiInterface $currentUserApi,
6870
UserRepositoryInterface $userRepository,
6971
ProfileTypeFactory $profileTypeFactory,
@@ -108,14 +110,14 @@ public function edit(
108110
$userEntity->delAttribute($attribute);
109111
}
110112
}
111-
$this->getDoctrine()->getManager()->flush();
113+
$doctrine->getManager()->flush();
112114
}
113115

114116
return $this->redirectToRoute('zikulaprofilemodule_profile_display', ['uid' => $userEntity->getUid()]);
115117
}
116118

117119
// detach user entity because attributes may be altered for the form (e.g. multiple choice fields)
118-
$this->getDoctrine()->getManager()->detach($userEntity);
120+
$doctrine->getManager()->detach($userEntity);
119121

120122
return [
121123
'user' => $userEntity,

Controller/PropertyController.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Zikula\ProfileModule\Controller;
1515

16+
use Doctrine\Persistence\ManagerRegistry;
1617
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
1718
use Symfony\Component\HttpFoundation\RedirectResponse;
1819
use Symfony\Component\HttpFoundation\Request;
@@ -52,7 +53,7 @@ public function listProperties(PropertyRepositoryInterface $propertyRepository):
5253
*
5354
* @return array|RedirectResponse
5455
*/
55-
public function edit(Request $request, PropertyEntity $propertyEntity = null)
56+
public function edit(Request $request, ManagerRegistry $doctrine, PropertyEntity $propertyEntity = null)
5657
{
5758
if (!isset($propertyEntity)) {
5859
$propertyEntity = new PropertyEntity();
@@ -62,8 +63,8 @@ public function edit(Request $request, PropertyEntity $propertyEntity = null)
6263
if ($form->isSubmitted() && $form->isValid()) {
6364
if ($form->get('save')->isClicked()) {
6465
$propertyEntity = $form->getData();
65-
$this->getDoctrine()->getManager()->persist($propertyEntity);
66-
$this->getDoctrine()->getManager()->flush();
66+
$doctrine->getManager()->persist($propertyEntity);
67+
$doctrine->getManager()->flush();
6768
$this->addFlash('success', $this->trans('Property saved.'));
6869
}
6970
if ($form->get('cancel')->isClicked()) {
@@ -85,15 +86,15 @@ public function edit(Request $request, PropertyEntity $propertyEntity = null)
8586
*
8687
* @return array|RedirectResponse
8788
*/
88-
public function delete(Request $request, PropertyEntity $propertyEntity)
89+
public function delete(Request $request, ManagerRegistry $doctrine, PropertyEntity $propertyEntity)
8990
{
9091
$form = $this->createForm(DeletionType::class, $propertyEntity);
9192
$form->handleRequest($request);
9293
if ($form->isSubmitted() && $form->isValid()) {
9394
if ($form->get('delete')->isClicked()) {
9495
$propertyEntity = $form->getData();
95-
$this->getDoctrine()->getManager()->remove($propertyEntity);
96-
$this->getDoctrine()->getManager()->flush();
96+
$doctrine->getManager()->remove($propertyEntity);
97+
$doctrine->getManager()->flush();
9798
$this->addFlash('success', $this->trans('Property removed.'));
9899
}
99100
if ($form->get('cancel')->isClicked()) {

Controller/UserBlockController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Zikula\ProfileModule\Controller;
1515

16+
use Doctrine\Persistence\ManagerRegistry;
1617
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
1718
use Symfony\Component\HttpFoundation\RedirectResponse;
1819
use Symfony\Component\HttpFoundation\Request;
@@ -40,6 +41,7 @@ class UserBlockController extends AbstractController
4041
*/
4142
public function edit(
4243
Request $request,
44+
ManagerRegistry $doctrine,
4345
BlockRepositoryInterface $blockRepository,
4446
CurrentUserApiInterface $currentUserApi,
4547
UserRepositoryInterface $userRepository
@@ -68,7 +70,7 @@ public function edit(
6870

6971
$userEntity->setAttribute('ublockon', $formData['ublockon']);
7072
$userEntity->setAttribute('ublock', $formData['ublock']);
71-
$this->getDoctrine()->getManager()->flush();
73+
$doctrine->getManager()->flush();
7274

7375
$this->addFlash('status', $this->trans('Done! Saved custom block.'));
7476
}

0 commit comments

Comments
 (0)