Skip to content

Commit

Permalink
avoid deprecation notices while running tests with Symfony >= 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
craue committed Aug 30, 2021
1 parent a90dbc8 commit 74fa53c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

namespace Craue\ConfigBundle\Controller;

use Craue\ConfigBundle\CacheAdapter\CacheAdapterInterface;
use Craue\ConfigBundle\Entity\SettingInterface;
use Craue\ConfigBundle\Form\ModifySettingsForm;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment;

/**
Expand All @@ -17,11 +21,11 @@
*/
class SettingsController extends AbstractController {

public function modifyAction(Request $request, FormFactoryInterface $formFactory, Environment $twig) {
$em = $this->getDoctrine()->getManager();
public function modifyAction(CacheAdapterInterface $cache, ManagerRegistry $doctrine, FormFactoryInterface $formFactory, Request $request, SessionInterface $session,
TranslatorInterface $translator, Environment $twig) {
$em = $doctrine->getManager();
$repo = $em->getRepository($this->container->getParameter('craue_config.entity_name'));
$allStoredSettings = $repo->findAll();
$cache = $this->get('craue_config_cache_adapter');

$formData = [
'settings' => $allStoredSettings,
Expand All @@ -43,8 +47,7 @@ public function modifyAction(Request $request, FormFactoryInterface $formFactory

$em->flush();

$this->get('session')->getFlashBag()->set('notice',
$this->get('translator')->trans('settings_changed', [], 'CraueConfigBundle'));
$session->getFlashBag()->set('notice', $translator->trans('settings_changed', [], 'CraueConfigBundle'));
return $this->redirect($this->generateUrl($this->container->getParameter('craue_config.redirectRouteAfterModify')));
}
}
Expand Down
3 changes: 3 additions & 0 deletions Resources/config/util.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<argument type="service" id="craue_config_cache_provider" on-invalid="ignore" />
</service>

<!-- autowiring alias -->
<service id="Craue\ConfigBundle\CacheAdapter\CacheAdapterInterface" alias="craue_config_cache_adapter" public="false" />

<service id="craue_config_default" class="Craue\ConfigBundle\Util\Config" public="true">
<argument type="service" id="craue_config_cache_adapter" />
<call method="setEntityManager">
Expand Down

0 comments on commit 74fa53c

Please sign in to comment.