for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Beelab\SimplePageBundle\Controller;
use Beelab\SimplePageBundle\Util\BreadCrumbs;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Twig\Environment;
class DefaultController
{
/**
* @var ManagerRegistry
*/
protected $doctrine;
* @var Environment
protected $twig;
* @var string
protected $entity;
protected $prefix;
public function __construct(ManagerRegistry $doctrine, Environment $twig, string $entity, string $prefix)
$this->doctrine = $doctrine;
$this->twig = $twig;
$this->entity = $entity;
$this->prefix = $prefix;
}
* You must define a final route in your configuration, pointing to this action.
public function showAction(string $path = ''): Response
$page = $this->doctrine->getRepository($this->entity)->findOneByPath($path);
findOneByPath()
Doctrine\Persistence\ObjectRepository
findOneBy()
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.
if (empty($page)) {
throw new NotFoundHttpException(\sprintf('Page not found for path "/%s".', $path));
$breadCrumbs = BreadCrumbs::create($path);
$template = $this->prefix.\str_replace(' ', '_', $page->getTemplate()).'.html.twig';
return new Response($this->twig->render($template, ['page' => $page, 'breadCrumbs' => $breadCrumbs]));
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.