diff --git a/.gitignore b/.gitignore index 136901b..626f3d2 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ /var/ /vendor/ ###< symfony/framework-bundle ### + +### IDE +.idea diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 5c98b42..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Default ignored files -/workspace.xml \ No newline at end of file diff --git a/.idea/api.iml b/.idea/api.iml deleted file mode 100644 index b28e377..0000000 --- a/.idea/api.iml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/git_toolbox_prj.xml b/.idea/git_toolbox_prj.xml deleted file mode 100644 index c7846c0..0000000 --- a/.idea/git_toolbox_prj.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 28a804d..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index d50cf45..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml deleted file mode 100644 index 3dc8b48..0000000 --- a/.idea/php.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..d09e88b --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +#Funky Framadate API +Experimental REST backend in symfony 4 for Funky framadate. diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml index 78d1310..1e2e3b6 100644 --- a/config/packages/doctrine.yaml +++ b/config/packages/doctrine.yaml @@ -1,26 +1,26 @@ doctrine: - dbal: - # configure these for your database server - # use postgresql for PostgreSQL - # use sqlite for SQLite - driver: 'mysql' - server_version: '5.7' + dbal: + # configure these for your database server + # use postgresql for PostgreSQL + # use sqlite for SQLite + driver: 'mysql' + server_version: '5.7' - # only needed for MySQL - charset: utf8mb4 - default_table_options: - charset: utf8mb4 - collate: utf8mb4_unicode_ci + # only needed for MySQL + charset: utf8mb4 + default_table_options: + charset: utf8mb4 + collate: utf8mb4_unicode_ci - url: '%env(resolve:DATABASE_URL)%' - orm: - auto_generate_proxy_classes: true - naming_strategy: doctrine.orm.naming_strategy.underscore - auto_mapping: true - mappings: - App: - is_bundle: false - type: annotation - dir: '%kernel.project_dir%/src/Entity' - prefix: 'App\Entity' - alias: App + url: '%env(resolve:DATABASE_URL)%' + orm: + auto_generate_proxy_classes: true + naming_strategy: doctrine.orm.naming_strategy.underscore + auto_mapping: true + mappings: + App: + is_bundle: false + type: annotation + dir: '%kernel.project_dir%/src/Entity' + prefix: 'App\Entity' + alias: App diff --git a/src/Entity/Owner.php b/src/Entity/Owner.php new file mode 100644 index 0000000..0a4b1f1 --- /dev/null +++ b/src/Entity/Owner.php @@ -0,0 +1,100 @@ +polls = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getEmail(): ?string + { + return $this->email; + } + + public function setEmail(string $email): self + { + $this->email = $email; + + return $this; + } + + public function getPseudo(): ?string + { + return $this->pseudo; + } + + public function setPseudo(string $pseudo): self + { + $this->pseudo = $pseudo; + + return $this; + } + + /** + * @return Collection|Poll[] + */ + public function getPolls(): Collection + { + return $this->polls; + } + + public function addPoll(Poll $poll): self + { + if (!$this->polls->contains($poll)) { + $this->polls[] = $poll; + $poll->setOwner($this); + } + + return $this; + } + + public function removePoll(Poll $poll): self + { + if ($this->polls->contains($poll)) { + $this->polls->removeElement($poll); + // set the owning side to null (unless already changed) + if ($poll->getOwner() === $this) { + $poll->setOwner(null); + } + } + + return $this; + } +} diff --git a/src/Entity/Poll.php b/src/Entity/Poll.php new file mode 100644 index 0000000..245f9aa --- /dev/null +++ b/src/Entity/Poll.php @@ -0,0 +1,131 @@ +votes = new ArrayCollection(); + } + + public function getId(): ?int { + return $this->id; + } + + public function getTitle(): ?string { + return $this->title; + } + + public function setTitle( string $title ): self { + $this->title = $title; + + return $this; + } + + public function getCreationDate(): ?\DateTimeInterface { + return $this->creationDate; + } + + public function setCreationDate( \DateTimeInterface $creationDate ): self { + $this->creationDate = $creationDate; + + return $this; + } + + public function getExpiracyDate(): ?\DateTimeInterface { + return $this->expiracyDate; + } + + public function setExpiracyDate( \DateTimeInterface $expiracyDate ): self { + $this->expiracyDate = $expiracyDate; + + return $this; + } + + public function getOwner(): ?Owner { + return $this->owner; + } + + public function setOwner( ?Owner $owner ): self { + $this->owner = $owner; + + return $this; + } + + /** + * @return Collection|Vote[] + */ + public function getVotes(): Collection + { + return $this->votes; + } + + public function addVote(Vote $vote): self + { + if (!$this->votes->contains($vote)) { + $this->votes[] = $vote; + $vote->setPoll($this); + } + + return $this; + } + + public function removeVote(Vote $vote): self + { + if ($this->votes->contains($vote)) { + $this->votes->removeElement($vote); + // set the owning side to null (unless already changed) + if ($vote->getPoll() === $this) { + $vote->setPoll(null); + } + } + + return $this; + } +} diff --git a/src/Entity/Vote.php b/src/Entity/Vote.php new file mode 100644 index 0000000..83f8b15 --- /dev/null +++ b/src/Entity/Vote.php @@ -0,0 +1,86 @@ +id; + } + + public function getAnswerTxt(): ?string { + return $this->answerTxt; + } + + public function setAnswerTxt( ?string $answerTxt ): self { + $this->answerTxt = $answerTxt; + + return $this; + } + + public function getAnswerDate(): ?\DateTimeInterface { + return $this->answerDate; + } + + public function setAnswerDate( ?\DateTimeInterface $answerDate ): self { + $this->answerDate = $answerDate; + + return $this; + } + + public function getCreationDate(): ?\DateTimeInterface { + return $this->creationDate; + } + + public function setCreationDate( \DateTimeInterface $creationDate ): self { + $this->creationDate = $creationDate; + + return $this; + } + + public function getPoll(): ?Poll { + return $this->poll; + } + + public function setPoll( ?Poll $poll ): self { + $this->poll = $poll; + + return $this; + } +} diff --git a/src/Repository/OwnerRepository.php b/src/Repository/OwnerRepository.php new file mode 100644 index 0000000..3bffacf --- /dev/null +++ b/src/Repository/OwnerRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('o') + ->andWhere('o.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('o.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Owner + { + return $this->createQueryBuilder('o') + ->andWhere('o.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/PollRepository.php b/src/Repository/PollRepository.php new file mode 100644 index 0000000..6762cad --- /dev/null +++ b/src/Repository/PollRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('p') + ->andWhere('p.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('p.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Poll + { + return $this->createQueryBuilder('p') + ->andWhere('p.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/VoteRepository.php b/src/Repository/VoteRepository.php new file mode 100644 index 0000000..a95a2fd --- /dev/null +++ b/src/Repository/VoteRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('v') + ->andWhere('v.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('v.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Vote + { + return $this->createQueryBuilder('v') + ->andWhere('v.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +}