* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace App\Entity; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity() * @ORM\Table(name="symfony_demo_tag") * * Defines the properties of the Tag entity to represent the post tags. * * See https://symfony.com/doc/current/doctrine.html#creating-an-entity-class * * @author Yonel Ceruto */ class Tag implements \JsonSerializable { /** * @var int * * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @var string * * @ORM\Column(type="string", unique=true) */ private $name; public function getId(): ?int { return $this->id; } public function setName(string $name): void { $this->name = $name; } public function getName(): ?string { return $this->name; } /** * {@inheritdoc} */ public function jsonSerialize(): string { // This entity implements JsonSerializable (http://php.net/manual/en/class.jsonserializable.php) // so this method is used to customize its JSON representation when json_encode() // is called, for example in tags|json_encode (templates/form/fields.html.twig) return $this->name; } public function __toString(): string { return $this->name; } }