From 100b928398fd30d07e6043763d66ccbb1d7af64c Mon Sep 17 00:00:00 2001 From: loic Date: Wed, 9 Aug 2017 10:07:16 +0200 Subject: [PATCH 1/5] Add location metadata --- src/AppBundle/Entity/Metadata.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/AppBundle/Entity/Metadata.php b/src/AppBundle/Entity/Metadata.php index 5f8a6b9..cbb2c7e 100644 --- a/src/AppBundle/Entity/Metadata.php +++ b/src/AppBundle/Entity/Metadata.php @@ -56,6 +56,26 @@ class Metadata */ private $format; + /** + * @var string + * + * @ORM\Column(name="location", type="string") + * @Assert\NotBlank + * @Groups({"video"}) + * @Assert\Type("string") + */ + private $location; + + public function getLocation(): string + { + return $this->location; + } + + public function setLocation(string $location) + { + $this->location = $location; + } + public function getId(): int { return $this->id; From 3c40b3bd09fbb80ceac6c53f661edca25728ca52 Mon Sep 17 00:00:00 2001 From: loic Date: Wed, 9 Aug 2017 10:07:39 +0200 Subject: [PATCH 2/5] Update filters for location search --- app/config/filters.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/config/filters.yml b/app/config/filters.yml index cc66af6..641bbad 100644 --- a/app/config/filters.yml +++ b/app/config/filters.yml @@ -18,3 +18,8 @@ services: parent: 'api_platform.doctrine.orm.search_filter' arguments: [ { video: 'exact' } ] tags: [ { name: 'api_platform.filter', id: 'view.search' } ] + + metadata.search_filter: + parent: 'api_platform.doctrine.orm.search_filter' + arguments: [ { location: 'exact' } ] + tags: [ { name: 'api_platform.filter', id: 'metadata.search' } ] \ No newline at end of file From 584dbb1a8a213642bbc10a5888e50d337b55e20b Mon Sep 17 00:00:00 2001 From: loic Date: Wed, 9 Aug 2017 10:31:25 +0200 Subject: [PATCH 3/5] Fix ApiResource line --- src/AppBundle/Entity/Metadata.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/AppBundle/Entity/Metadata.php b/src/AppBundle/Entity/Metadata.php index cbb2c7e..b538fd2 100644 --- a/src/AppBundle/Entity/Metadata.php +++ b/src/AppBundle/Entity/Metadata.php @@ -11,7 +11,7 @@ * Metadata. * * @ORM\Entity - * @ApiResource + * @ApiResource(attributes={"filters" = {"metadata.search"}}) */ class Metadata { @@ -57,7 +57,7 @@ class Metadata private $format; /** - * @var string + * @var string The upload country of the video * * @ORM\Column(name="location", type="string") * @Assert\NotBlank @@ -66,16 +66,6 @@ class Metadata */ private $location; - public function getLocation(): string - { - return $this->location; - } - - public function setLocation(string $location) - { - $this->location = $location; - } - public function getId(): int { return $this->id; @@ -123,4 +113,17 @@ public function setFormat(string $format): Metadata return $this; } + + public function getLocation(): string + { + return $this->location; + } + + public function setLocation(string $location): Metadata + { + $this->location = $location; + + return $this; + } + } From 1bf0442ca86c994434146e9003485c7ccdd331f6 Mon Sep 17 00:00:00 2001 From: loic Date: Thu, 10 Aug 2017 14:08:44 +0200 Subject: [PATCH 4/5] Move location to specific file --- src/AppBundle/Entity/Location.php | 66 +++++++++++++++++++++++++++++++ src/AppBundle/Entity/Metadata.php | 8 ++-- 2 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 src/AppBundle/Entity/Location.php diff --git a/src/AppBundle/Entity/Location.php b/src/AppBundle/Entity/Location.php new file mode 100644 index 0000000..7500f81 --- /dev/null +++ b/src/AppBundle/Entity/Location.php @@ -0,0 +1,66 @@ +latitude; + } + + /** + * @param mixed $latitude + */ + public function setLatitude($latitude) + { + $this->latitude = $latitude; + } + + /** + * @return mixed + */ + public function getLongitude() + { + return $this->longitude; + } + + /** + * @param mixed $longitude + */ + public function setLongitude($longitude) + { + $this->longitude = $longitude; + } + +} \ No newline at end of file diff --git a/src/AppBundle/Entity/Metadata.php b/src/AppBundle/Entity/Metadata.php index b538fd2..acd6a76 100644 --- a/src/AppBundle/Entity/Metadata.php +++ b/src/AppBundle/Entity/Metadata.php @@ -57,12 +57,10 @@ class Metadata private $format; /** - * @var string The upload country of the video + * @var location * - * @ORM\Column(name="location", type="string") - * @Assert\NotBlank + * @ORM\OneToOne(targetEntity="AppBundle\Entity\Location", cascade={"persist"}) * @Groups({"video"}) - * @Assert\Type("string") */ private $location; @@ -114,7 +112,7 @@ public function setFormat(string $format): Metadata return $this; } - public function getLocation(): string + public function getLocation() { return $this->location; } From 4546a595deda7e2fb1b11da2a27f35a9268dfe04 Mon Sep 17 00:00:00 2001 From: loic Date: Thu, 10 Aug 2017 15:26:24 +0200 Subject: [PATCH 5/5] Use ManyToOne instead OneToOne --- src/AppBundle/Entity/Location.php | 25 +++++++++++++++++++++++++ src/AppBundle/Entity/Metadata.php | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/AppBundle/Entity/Location.php b/src/AppBundle/Entity/Location.php index 7500f81..58bb552 100644 --- a/src/AppBundle/Entity/Location.php +++ b/src/AppBundle/Entity/Location.php @@ -31,6 +31,31 @@ class Location */ protected $longitude; + + /** + * @var Metadata + * + * @ORM\OneToMany(targetEntity="AppBundle\Entity\Metadata", mappedBy="location", cascade={"persist"}) + * @Groups({"video"}) + */ + private $metadata; + + /** + * @return Metadata + */ + public function getMetadata(): Metadata + { + return $this->metadata; + } + + /** + * @param Metadata $metadata + */ + public function setMetadata(Metadata $metadata) + { + $this->metadata = $metadata; + } + /** * @return mixed */ diff --git a/src/AppBundle/Entity/Metadata.php b/src/AppBundle/Entity/Metadata.php index acd6a76..ad680b5 100644 --- a/src/AppBundle/Entity/Metadata.php +++ b/src/AppBundle/Entity/Metadata.php @@ -59,7 +59,7 @@ class Metadata /** * @var location * - * @ORM\OneToOne(targetEntity="AppBundle\Entity\Location", cascade={"persist"}) + * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Location", inversedBy="matadata") * @Groups({"video"}) */ private $location;