You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During the Chapter "Managing the Lifecycle of Doctrine Objects", one is asked to create a Doctrine entity listener. With a block of code to copy.
The code block forgets to add a <?php tag in the beginning, resulting in the document being displayed as HTML Text over the website.
Without knowing about the needed tag, this is a weird behaviour without obvious solution.
The fixed code would be
<?php
namespace App\EntityListener;
use App\Entity\Conference;
use Doctrine\Persistence\Event\LifecycleEventArgs;
use Symfony\Component\String\Slugger\SluggerInterface;
class ConferenceEntityListener
{
public function __construct(
private SluggerInterface $slugger,
) {
}
public function prePersist(Conference $conference, LifecycleEventArgs $event)
{
$conference->computeSlug($this->slugger);
}
public function preUpdate(Conference $conference, LifecycleEventArgs $event)
{
$conference->computeSlug($this->slugger);
}
}
The text was updated successfully, but these errors were encountered:
During the Chapter "Managing the Lifecycle of Doctrine Objects", one is asked to create a Doctrine entity listener. With a block of code to copy.
The code block forgets to add a <?php tag in the beginning, resulting in the document being displayed as HTML Text over the website.
Without knowing about the needed tag, this is a weird behaviour without obvious solution.
The fixed code would be
The text was updated successfully, but these errors were encountered: