Skip to content

Commit

Permalink
sf4.2 port: Twig filter+extension deprecation fix. Section Portlet Page
Browse files Browse the repository at this point in the history
ported.
  • Loading branch information
pascallapointe committed May 15, 2019
1 parent 434b34a commit 53e2815
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 291 deletions.
11 changes: 7 additions & 4 deletions src/Controller/Site/MetadataController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

namespace App\Controller\Site;

use App\Library\BaseController;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\Response;
use App\Library\BaseController;
use Tutoriux\DoctrineBehaviorsBundle\ORM\Metadatable\MetadatableGetter;

/**
Expand All @@ -14,12 +15,14 @@ class MetadataController extends BaseController
{
/**
* @param MetadatableGetter $metadatableGetter
* @param ParameterBagInterface $parameterBag
* @param $metaName
* @param bool $ogMeta
* @param bool $forceEmpty
* @return Response
*/
public function metadata(MetadatableGetter $metadatableGetter, $metaName, $ogMeta = false, $forceEmpty = false)
public function metadata(MetadatableGetter $metadatableGetter, ParameterBagInterface $parameterBag,
$metaName, $ogMeta = false, $forceEmpty = false)
{
$response = new Response();
$response->setPublic();
Expand All @@ -32,8 +35,8 @@ public function metadata(MetadatableGetter $metadatableGetter, $metaName, $ogMet
if (!$value && !$forceEmpty) {
$parameter = sprintf('tutoriux.metadata.%s', $metaName);

if ($this->container->hasParameter($parameter)) {
$value = $this->container->getParameter($parameter);
if ($parameterBag->has($parameter)) {
$value = $parameterBag->get($parameter);
}
}

Expand Down
16 changes: 7 additions & 9 deletions src/Controller/Site/SectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

namespace App\Controller\Site;

use Symfony\Component\HttpFoundation\Request,
Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

use App\Repository\TextRepository;
use App\Library\BaseController;
use App\Services\DoctrineInit;
use App\Entity\Text;

/**
* Class SectionController
Expand All @@ -27,10 +28,9 @@ public function homePage()
}

/**
* @param Request $request
* @return Response
*/
public function quickTour(Request $request)
public function quickTour()
{
$response = new Response();
$response->setPublic();
Expand All @@ -46,15 +46,13 @@ public function quickTour(Request $request)
/**
* @param Request $request
* @return Response
* @throws \Doctrine\ORM\ORMException
*/
public function portlet(Request $request)
{
$sectionId = $this->getSection()->getId();

/** @var TextRepository $textRepository */
$textRepository = $this->get(DoctrineInit::class)
->initRepository($this->getEm()->getRepository('SystemBundle:Text'));
$textRepository = $this->getRepository(Text::class);
$textLastUpdate = $textRepository->findLastUpdate(null, $sectionId);

$response = new Response();
Expand All @@ -65,13 +63,13 @@ public function portlet(Request $request)
return $response;
}

$texts = $this->getEm()->getRepository('SystemBundle:Text')->findBy(
$texts = $textRepository->findBy(
['section' => $sectionId, 'static' => false, 'active' => true],
['ordering' => 'ASC']
);

return $this->render(
'SystemBundle:Frontend/Section:portlet.html.twig',
'site/section/portlet.html.twig',
['texts' => $texts],
$response
);
Expand Down
Loading

0 comments on commit 53e2815

Please sign in to comment.