Skip to content

Instantly share code, notes, and snippets.

@SilentKernel
Created May 24, 2021 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SilentKernel/0c92fc683f712b7d8a039e52068bf4ae to your computer and use it in GitHub Desktop.
Save SilentKernel/0c92fc683f712b7d8a039e52068bf4ae to your computer and use it in GitHub Desktop.
<?php
namespace App\Entity;
class BlogArticle
{
// ... Les autres attribus de la classe
/**
* @ORM\Column(type="json")
*/
private $oldSlugs = [];
// ... les getter et setter de la classe
/**
* @param string|null $title
*/
public function setTitle(?string $title): void
{
if ($this->slug !== null) {
// Ici on sauvegarde l'ancien slug avant un changement
$this->oldSlugs[] = $this->slug;
}
$this->title = $title;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment