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

Commit

Permalink
remove deprecated usage of getDoctrine() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Guite committed Dec 2, 2021
1 parent af114fb commit 902599d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
6 changes: 4 additions & 2 deletions Controller/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Zikula\ProfileModule\Controller;

use Doctrine\Persistence\ManagerRegistry;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\RedirectResponse;
Expand Down Expand Up @@ -64,6 +65,7 @@ public function display(
*/
public function edit(
Request $request,
ManagerRegistry $doctrine,
CurrentUserApiInterface $currentUserApi,
UserRepositoryInterface $userRepository,
ProfileTypeFactory $profileTypeFactory,
Expand Down Expand Up @@ -108,14 +110,14 @@ public function edit(
$userEntity->delAttribute($attribute);
}
}
$this->getDoctrine()->getManager()->flush();
$doctrine->getManager()->flush();
}

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

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

return [
'user' => $userEntity,
Expand Down
13 changes: 7 additions & 6 deletions Controller/PropertyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Zikula\ProfileModule\Controller;

use Doctrine\Persistence\ManagerRegistry;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -52,7 +53,7 @@ public function listProperties(PropertyRepositoryInterface $propertyRepository):
*
* @return array|RedirectResponse
*/
public function edit(Request $request, PropertyEntity $propertyEntity = null)
public function edit(Request $request, ManagerRegistry $doctrine, PropertyEntity $propertyEntity = null)
{
if (!isset($propertyEntity)) {
$propertyEntity = new PropertyEntity();
Expand All @@ -62,8 +63,8 @@ public function edit(Request $request, PropertyEntity $propertyEntity = null)
if ($form->isSubmitted() && $form->isValid()) {
if ($form->get('save')->isClicked()) {
$propertyEntity = $form->getData();
$this->getDoctrine()->getManager()->persist($propertyEntity);
$this->getDoctrine()->getManager()->flush();
$doctrine->getManager()->persist($propertyEntity);
$doctrine->getManager()->flush();
$this->addFlash('success', $this->trans('Property saved.'));
}
if ($form->get('cancel')->isClicked()) {
Expand All @@ -85,15 +86,15 @@ public function edit(Request $request, PropertyEntity $propertyEntity = null)
*
* @return array|RedirectResponse
*/
public function delete(Request $request, PropertyEntity $propertyEntity)
public function delete(Request $request, ManagerRegistry $doctrine, PropertyEntity $propertyEntity)
{
$form = $this->createForm(DeletionType::class, $propertyEntity);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
if ($form->get('delete')->isClicked()) {
$propertyEntity = $form->getData();
$this->getDoctrine()->getManager()->remove($propertyEntity);
$this->getDoctrine()->getManager()->flush();
$doctrine->getManager()->remove($propertyEntity);
$doctrine->getManager()->flush();
$this->addFlash('success', $this->trans('Property removed.'));
}
if ($form->get('cancel')->isClicked()) {
Expand Down
4 changes: 3 additions & 1 deletion Controller/UserBlockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Zikula\ProfileModule\Controller;

use Doctrine\Persistence\ManagerRegistry;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -40,6 +41,7 @@ class UserBlockController extends AbstractController
*/
public function edit(
Request $request,
ManagerRegistry $doctrine,
BlockRepositoryInterface $blockRepository,
CurrentUserApiInterface $currentUserApi,
UserRepositoryInterface $userRepository
Expand Down Expand Up @@ -68,7 +70,7 @@ public function edit(

$userEntity->setAttribute('ublockon', $formData['ublockon']);
$userEntity->setAttribute('ublock', $formData['ublock']);
$this->getDoctrine()->getManager()->flush();
$doctrine->getManager()->flush();

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

0 comments on commit 902599d

Please sign in to comment.