before recipes:update

This commit is contained in:
2022-05-11 14:48:04 +02:00
parent 1b4ca82754
commit c84ec14cb5
46 changed files with 1363 additions and 1235 deletions

@@ -10,27 +10,27 @@ use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ProjectsRepository::class)]
#[ApiResource]
class Projects
class Projects implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id;
private ?int $id = null;
#[ORM\Column(type: 'string', length: 255)]
private ?string $name;
private ?string $name = null;
#[ORM\Column(type: 'string', length: 255)]
private ?string $description;
private ?string $description = null;
#[ORM\Column(type: 'string', length: 255)]
private ?string $url;
private ?string $url = null;
#[ORM\Column(type: 'datetime_immutable')]
private ?\DateTimeImmutable $createdAt;
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $teaserImage;
private ?string $teaserImage = null;
#[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'projects')]
private $developer;
@@ -43,9 +43,9 @@ class Projects
/**
* @return string|null
*/
public function __toString()
public function __toString(): string
{
return $this->name;
return (string) $this->name;
}
public function getId(): ?int

@@ -15,16 +15,17 @@ use Symfony\Component\Security\Core\User\UserInterface;
/**
* => ["security" => "is_granted('ROLE_ADMIN') or object.owner == user"]
attributes : ['security' => 'is_granted("ROLE_USER")']
*/
#[ORM\Entity(repositoryClass: UserRepository::class), ORM\HasLifecycleCallbacks]
#[ApiResource(
collectionOperations: ['get', 'post'],
itemOperations : ['get'],
attributes : ['security' => 'is_granted("ROLE_USER")']
)]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['username' => 'exact'])]
class User implements UserInterface, PasswordAuthenticatedUserInterface
class User implements UserInterface, PasswordAuthenticatedUserInterface, \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
@@ -55,7 +56,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
private $projects;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $avatar;
private string $avatar;
#[ORM\OneToMany(mappedBy: 'owner', targetEntity: Pages::class)]
private $pages;
@@ -75,7 +76,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
/**
* @return string|null
*/
public function __toString()
public function __toString(): string
{
return $this->username;
}
@@ -244,9 +245,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
public function addPage(Pages $page): self
{
if (!$this->pages->contains($page)) {
if (!$this->pages->contains(element: $page)) {
$this->pages[] = $page;
$page->setOwner($this);
$page->setOwner(owner: $this);
}
return $this;
@@ -254,10 +255,10 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
public function removePage(Pages $page): self
{
if ($this->pages->removeElement($page)) {
if ($this->pages->removeElement(element: $page)) {
// set the owning side to null (unless already changed)
if ($page->getOwner() === $this) {
$page->setOwner(null);
$page->setOwner(owner: null);
}
}
@@ -287,8 +288,11 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
return $this;
}
public function getAvatarUri()
/**
* @return string
*/
public function getAvatarUri()
{
return 'avatar';
}