captcha = $c; return $this; } public function getCaptcha(): ?string { return $this->captcha; } public function getTitle(): ?string { return $this->title; } public function setTitle(string $n): self { $this->title = $n; return $this; } public function getSlug(): ?string { return $this->slug; } protected function setSlug(string $s): self { $this->slug = $s; return $this; } public function getContactEmail(): ?string { return $this->contactEmail; } public function setContactEmail(string $e): self { $this->contactEmail = $e; return $this; } public function getContactPhone(): ?string { return $this->contactPhone; } public function setContactPhone(string $s): self { $this->contactPhone = $s; return $this; } public function getBookingUrl(): ?string { return $this->bookingUrl; } public function setBookingUrl($s): self { $this->bookingUrl = $s; return $this; } public function getWebsiteUrl(): ?string { return $this->websiteUrl; } public function setWebsiteUrl(string $s): self { $this->websiteUrl = $s; return $this; } public function getCapacity(): ?string { return $this->capacity; } public function setCapacity(string $i): self { $this->capacity= $i; return $this; } public function getPlace(): ?string { return $this->place; } public function setPlace(string $s): self { $this->place = $s; return $this; } public function getContactPerson(): ?string { return $this->contactPerson; } public function setContactPerson(string $s): self { $this->contactPerson = $s; return $this; } public function getOrganizationNumber(): ?string { return $this->organizationNumber; } public function setOrganizationNumber(string $s): self { $this->organizationNumber = $s; return $this; } public function getOrganizer(): ?string { return $this->organizer; } public function setOrganizer(string $s): self { $this->organizer = $s; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(string $s): self { $this->description = sprintf('

%s

', preg_replace('/[\\n]+/', '

', strip_tags($s))); return $this; } public function getImage() { return $this->image; } public function setImage($a): self { $this->image = $a; if (is_string($this->image)) $this->bilde; return $this; } public function getBilde() { return $this->image; } public function getCategories(): ?array { $this->categories = array_map(function ($category) { return $category; }, $this->categories); return $this->categories; } public function setCategories(array $a): self { return $this->setKategorier($a); } protected function setKategorier(array $a): self { $this->categories = $a; return $this; } public function getAudiences(): ?array { $this->audiences = array_map(function ($audience) { return $audience; }, $this->audiences); return $this->audiences; } public function setAudiences(array $a): self { $this->audiences = $a; return $this; } public function getHappensOn(): ?array { return $this->happensOn; } public function setHappensOn(array $a): self { $this->happensOn = $a; return $this; } public function getFeatured(): ?bool { return $this->featured; } protected function setFeatured(bool $f): self { $this->featured = $f; return $this; } /** * @Assert\Callback */ public function validate(ExecutionContextInterface $context, $payload) { $happens = $this->getHappensOn(); $violation = false; foreach ($happens as $key => $value) { $duration = floatval($value['duration'] ?? 0.0); if ($duration < 0.25 || $duration > 24.0) { $context->buildViolation("Varighet må være angitt og mellom 0.25 og 24")->addViolation(); $violation = true; } $date = new \DateTime($value['date'] ?? "2005-05-05 05:05:05"); $fStart = new \DateTime('2020-06-25 00:00:01'); $fEnd = new \DateTime('2020-08-09 23:59:00'); if ($date < $fStart || $date > $fEnd) { $context->buildViolation("Eventet må skje mellom 25/6 - 09/8, år 2020.")->addViolation(); $violation = true; } if ($violation) break; } } }