Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metadata location #23

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/config/filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' } ]
91 changes: 91 additions & 0 deletions src/AppBundle/Entity/Location.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php


namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
* Class Location.
*
* @ORM\Entity
*/
class Location
{

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the blank line

/**
*
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the two empty lines

* @ORM\Column(type="decimal", scale="8")
* @Assert\NotBlank()
*/
protected $latitude;


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove one blank line

/**
*
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the two blank lines

* @ORM\Column(type="decimal", scale="8")
* @Assert\NotBlank()
*/
protected $longitude;


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the blank line

/**
* @var Metadata
*
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Metadata", mappedBy="location", cascade={"persist"})
* @Groups({"video"})
*/
private $metadata;

/**
* @return Metadata
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all the annotation blocks from the methods

*/
public function getMetadata(): Metadata
{
return $this->metadata;
}

/**
* @param Metadata $metadata
*/
public function setMetadata(Metadata $metadata)
{
$this->metadata = $metadata;
}

/**
* @return mixed
*/
public function getLatitude()
{
return $this->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;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the blank line

}
23 changes: 22 additions & 1 deletion src/AppBundle/Entity/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Metadata.
*
* @ORM\Entity
* @ApiResource
* @ApiResource(attributes={"filters" = {"metadata.search"}})
*/
class Metadata
{
Expand Down Expand Up @@ -56,6 +56,14 @@ class Metadata
*/
private $format;

/**
* @var location
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Location", inversedBy="matadata")
* @Groups({"video"})
*/
private $location;

public function getId(): int
{
return $this->id;
Expand Down Expand Up @@ -103,4 +111,17 @@ public function setFormat(string $format): Metadata

return $this;
}

public function getLocation()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return type is missing (here it should be ?Location)

{
return $this->location;
}

public function setLocation(string $location): Metadata
{
$this->location = $location;

return $this;
}

}