before recepie upgrade
This commit is contained in:
assets
bin
composer.jsoncomposer.lockconfig
migrations
src
Controller
Entity
EntityListener
Form
Security
templates
@@ -7,11 +7,13 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use App\Repository\SectionRepository;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Symfony\Component\String\Slugger\SluggerInterface;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=BlogRepository::class)
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
* @UniqueEntity("slug")
|
||||
*/
|
||||
class Blog
|
||||
{
|
||||
@@ -79,7 +81,7 @@ class Blog
|
||||
private $comments;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
* @ORM\Column(type="string", length=255, unique=true)
|
||||
*/
|
||||
private $slug;
|
||||
|
||||
@@ -274,7 +276,24 @@ class Blog
|
||||
public function setSlug(string $slug): self
|
||||
{
|
||||
$this->slug = $slug;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\PrePersist
|
||||
*/
|
||||
public function onPrePersist()
|
||||
{
|
||||
$this->createdAt = new \DateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SluggerInterface $slugger
|
||||
*/
|
||||
public function computeSlug(SluggerInterface $slugger)
|
||||
{
|
||||
$this->slug = $slugger->slug($this->title);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user