2025-05-26 11:32:53 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Entity;
|
|
|
|
|
|
|
|
use App\Repository\PlaceRepository;
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
use Doctrine\Common\Collections\Collection;
|
|
|
|
use Doctrine\DBAL\Types\Types;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
2025-05-29 16:50:25 +02:00
|
|
|
// use App\Service\Motocultrice;
|
2025-05-26 11:32:53 +02:00
|
|
|
#[ORM\Entity(repositoryClass: PlaceRepository::class)]
|
|
|
|
class Place
|
|
|
|
{
|
|
|
|
#[ORM\Id]
|
|
|
|
#[ORM\GeneratedValue]
|
|
|
|
#[ORM\Column]
|
|
|
|
private ?int $id = null;
|
|
|
|
|
|
|
|
#[ORM\Column(length: 50)]
|
|
|
|
private ?string $uuid_for_url = null;
|
|
|
|
|
|
|
|
#[ORM\Column(length: 10)]
|
|
|
|
private ?string $osm_kind = null;
|
|
|
|
|
|
|
|
#[ORM\Column(length: 255)]
|
|
|
|
private ?string $email = null;
|
|
|
|
|
|
|
|
#[ORM\Column]
|
|
|
|
private ?bool $opted_out = null;
|
|
|
|
|
|
|
|
#[ORM\Column]
|
|
|
|
private ?bool $dead = null;
|
|
|
|
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
|
|
private ?string $note = null;
|
|
|
|
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
|
|
private ?\DateTime $modified_date = null;
|
|
|
|
|
|
|
|
#[ORM\Column(type: Types::INTEGER)]
|
|
|
|
private ?int $zip_code = null;
|
|
|
|
|
|
|
|
#[ORM\Column]
|
|
|
|
private ?bool $asked_humains_support = null;
|
|
|
|
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
|
|
private ?\DateTime $last_contact_attempt_date = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var Collection<int, History>
|
|
|
|
*/
|
|
|
|
#[ORM\OneToMany(targetEntity: History::class, mappedBy: 'place_id', orphanRemoval: true)]
|
|
|
|
private Collection $histories;
|
|
|
|
|
|
|
|
#[ORM\ManyToOne(inversedBy: 'places')]
|
|
|
|
private ?Stats $stats = null;
|
|
|
|
|
|
|
|
#[ORM\Column(type: Types::BIGINT)]
|
|
|
|
private ?string $osmId = null;
|
|
|
|
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
|
|
private ?string $name = null;
|
|
|
|
|
2025-05-26 23:51:46 +02:00
|
|
|
#[ORM\Column(nullable: true)]
|
|
|
|
private ?bool $has_opening_hours = null;
|
|
|
|
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
|
|
private ?bool $has_address = null;
|
|
|
|
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
|
|
private ?bool $has_website = null;
|
|
|
|
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
|
|
private ?bool $has_wheelchair = null;
|
|
|
|
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
|
|
private ?bool $has_note = null;
|
|
|
|
|
2025-06-01 19:52:56 +02:00
|
|
|
#[ORM\Column(nullable: true)]
|
|
|
|
private ?string $main_tag = null;
|
|
|
|
|
2025-06-01 23:35:15 +02:00
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
|
|
private ?string $note_content = null;
|
|
|
|
|
2025-06-01 19:52:56 +02:00
|
|
|
public function getMainTag(): ?string
|
|
|
|
{
|
|
|
|
return $this->main_tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setMainTag(?string $main_tag): static
|
|
|
|
{
|
|
|
|
$this->main_tag = $main_tag;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-06-01 18:56:01 +02:00
|
|
|
public function getCompletionPercentage(): ?int
|
|
|
|
{
|
|
|
|
$completion_percentage = 0;
|
|
|
|
$total_fields = 5;
|
|
|
|
$filled_fields = 0;
|
|
|
|
if ($this->has_opening_hours) {
|
|
|
|
$filled_fields += 1;
|
|
|
|
}
|
|
|
|
if ($this->has_address) {
|
|
|
|
$filled_fields += 1;
|
|
|
|
}
|
|
|
|
if ($this->has_website) {
|
|
|
|
$filled_fields += 1;
|
|
|
|
}
|
|
|
|
if ($this->has_wheelchair) {
|
|
|
|
$filled_fields += 1;
|
|
|
|
}
|
|
|
|
if ($this->has_note) {
|
|
|
|
$filled_fields += 1;
|
|
|
|
}
|
|
|
|
return round($filled_fields / $total_fields * 100);
|
|
|
|
}
|
|
|
|
public function update_place_from_overpass_data(array $overpass_data) {
|
2025-05-29 16:50:25 +02:00
|
|
|
$overpass_data = $overpass_data['tags_converted'] ;
|
|
|
|
|
|
|
|
// Remplir les clés attendues avec des valeurs par défaut si non définies
|
|
|
|
$overpass_data = array_merge([
|
|
|
|
'id' => '',
|
|
|
|
'type' => '',
|
|
|
|
'name' => '',
|
|
|
|
'postcode' => '',
|
|
|
|
'email' => '',
|
|
|
|
'opening_hours' => '',
|
|
|
|
'addr:housenumber' => '',
|
|
|
|
'addr:street' => '',
|
|
|
|
'website' => '',
|
|
|
|
'wheelchair' => '',
|
|
|
|
'note' => ''
|
|
|
|
], $overpass_data);
|
|
|
|
|
|
|
|
$this
|
|
|
|
// ->setOsmId($overpass_data['id'])
|
|
|
|
// ->setOsmKind($overpass_data['type'])
|
|
|
|
->setName($overpass_data['name'])
|
|
|
|
->setZipCode(\intval($overpass_data['postcode']))
|
|
|
|
->setEmail($overpass_data['email'])
|
|
|
|
// ->setUuidForUrl( Motocultrice::uuid_create_static())
|
|
|
|
// ->setOptedOut(false)
|
|
|
|
// ->setDead(false)
|
|
|
|
->setHasOpeningHours($overpass_data['opening_hours'] ? true : false)
|
|
|
|
->setHasAddress($overpass_data['addr:housenumber'] && $overpass_data['addr:street'] ? true : false)
|
|
|
|
->setHasWebsite($overpass_data['website'] ? true : false)
|
|
|
|
->setHasWheelchair($overpass_data['wheelchair'] and $overpass_data['wheelchair'] != '' ? true : false)
|
|
|
|
->setHasNote($overpass_data['note'] and $overpass_data['note'] != '' ? true : false);
|
|
|
|
}
|
|
|
|
|
2025-05-26 11:32:53 +02:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->histories = new ArrayCollection();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getId(): ?int
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUuidForUrl(): ?string
|
|
|
|
{
|
|
|
|
return $this->uuid_for_url;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setUuidForUrl(string $uuid_for_url): static
|
|
|
|
{
|
|
|
|
$this->uuid_for_url = $uuid_for_url;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getOsmKind(): ?string
|
|
|
|
{
|
|
|
|
return $this->osm_kind;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOsmKind(string $osm_kind): static
|
|
|
|
{
|
|
|
|
$this->osm_kind = $osm_kind;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEmail(): ?string
|
|
|
|
{
|
|
|
|
return $this->email;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setEmail(string $email): static
|
|
|
|
{
|
|
|
|
$this->email = $email;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isOptedOut(): ?bool
|
|
|
|
{
|
|
|
|
return $this->opted_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOptedOut(bool $opted_out): static
|
|
|
|
{
|
|
|
|
$this->opted_out = $opted_out;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isDead(): ?bool
|
|
|
|
{
|
|
|
|
return $this->dead;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setDead(bool $dead): static
|
|
|
|
{
|
|
|
|
$this->dead = $dead;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getNote(): ?string
|
|
|
|
{
|
|
|
|
return $this->note;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setNote(?string $note): static
|
|
|
|
{
|
|
|
|
$this->note = $note;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getModifiedDate(): ?\DateTime
|
|
|
|
{
|
|
|
|
return $this->modified_date;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setModifiedDate(?\DateTime $modified_date): static
|
|
|
|
{
|
|
|
|
$this->modified_date = $modified_date;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getZipCode(): ?int
|
|
|
|
{
|
|
|
|
return $this->zip_code;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setZipCode(int $zip_code): static
|
|
|
|
{
|
|
|
|
$this->zip_code = $zip_code;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isAskedHumainsSupport(): ?bool
|
|
|
|
{
|
|
|
|
return $this->asked_humains_support;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setAskedHumainsSupport(bool $asked_humains_support): static
|
|
|
|
{
|
|
|
|
$this->asked_humains_support = $asked_humains_support;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLastContactAttemptDate(): ?\DateTime
|
|
|
|
{
|
|
|
|
return $this->last_contact_attempt_date;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setLastContactAttemptDate(?\DateTime $last_contact_attempt_date): static
|
|
|
|
{
|
|
|
|
$this->last_contact_attempt_date = $last_contact_attempt_date;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Collection<int, History>
|
|
|
|
*/
|
|
|
|
public function getHistories(): Collection
|
|
|
|
{
|
|
|
|
return $this->histories;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addHistory(History $history): static
|
|
|
|
{
|
|
|
|
if (!$this->histories->contains($history)) {
|
|
|
|
$this->histories->add($history);
|
|
|
|
$history->setPlaceId($this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function removeHistory(History $history): static
|
|
|
|
{
|
|
|
|
if ($this->histories->removeElement($history)) {
|
|
|
|
// set the owning side to null (unless already changed)
|
|
|
|
if ($history->getPlaceId() === $this) {
|
|
|
|
$history->setPlaceId(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getStats(): ?Stats
|
|
|
|
{
|
|
|
|
return $this->stats;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setStats(?Stats $stats): static
|
|
|
|
{
|
|
|
|
$this->stats = $stats;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getOsmId(): ?string
|
|
|
|
{
|
|
|
|
return $this->osmId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOsmId(string $osmId): static
|
|
|
|
{
|
|
|
|
$this->osmId = $osmId;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(): ?string
|
|
|
|
{
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setName(?string $name): static
|
|
|
|
{
|
|
|
|
$this->name = $name;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2025-05-26 23:51:46 +02:00
|
|
|
|
|
|
|
public function hasOpeningHours(): ?bool
|
|
|
|
{
|
|
|
|
return $this->has_opening_hours;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHasOpeningHours(?bool $has_opening_hours): static
|
|
|
|
{
|
|
|
|
$this->has_opening_hours = $has_opening_hours;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasAddress(): ?bool
|
|
|
|
{
|
|
|
|
return $this->has_address;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHasAddress(?bool $has_address): static
|
|
|
|
{
|
|
|
|
$this->has_address = $has_address;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasWebsite(): ?bool
|
|
|
|
{
|
|
|
|
return $this->has_website;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHasWebsite(?bool $has_website): static
|
|
|
|
{
|
|
|
|
$this->has_website = $has_website;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasWheelchair(): ?bool
|
|
|
|
{
|
|
|
|
return $this->has_wheelchair;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHasWheelchair(?bool $has_wheelchair): static
|
|
|
|
{
|
|
|
|
$this->has_wheelchair = $has_wheelchair;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasNote(): ?bool
|
|
|
|
{
|
|
|
|
return $this->has_note;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHasNote(?bool $has_note): static
|
|
|
|
{
|
|
|
|
$this->has_note = $has_note;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getPlaceCount(): ?int
|
|
|
|
{
|
|
|
|
return $this->place_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setPlaceCount(int $place_count): static
|
|
|
|
{
|
|
|
|
$this->place_count = $place_count;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2025-06-01 23:35:15 +02:00
|
|
|
|
|
|
|
public function getNoteContent(): ?string
|
|
|
|
{
|
|
|
|
return $this->note_content;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setNoteContent(?string $note_content): static
|
|
|
|
{
|
|
|
|
$this->note_content = $note_content;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2025-05-26 11:32:53 +02:00
|
|
|
}
|