Skip to content

Instantly share code, notes, and snippets.

@bastien70
Last active May 29, 2021 13:45
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 bastien70/859da9286ceb6705f1edd28337e4bc1f to your computer and use it in GitHub Desktop.
Save bastien70/859da9286ceb6705f1edd28337e4bc1f to your computer and use it in GitHub Desktop.
<?php
namespace App\Dto;
use App\Entity\User;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\SerializedName;
class CheeseListingInput
{
#[Groups(['cheese:write', 'user:write'])]
public ?string $title = null;
#[Groups(['cheese:write', 'user:write'])]
public ?int $price = null;
#[Groups(['cheese:collection:post'])]
public ?User $owner = null;
#[Groups(['cheese:write'])]
public ?bool $isPublished = false;
public ?string $description = null;
/**
* The description of the cheese as raw text.
* @param string $description
* @return $this
*/
#[
Groups(['cheese:write', 'user:write']),
SerializedName('description')
]
public function setTextDescription(string $description): self
{
$this->description = nl2br($description);
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment