*/ public function __construct() { $this->endpoints = new ArrayCollection(); } /** * @return int * @author Soner Sayakci */ public function getId() : int { return $this->id; } /** * @return null|string * @author Soner Sayakci */ public function getName(): ?string { return $this->name; } /** * @param string $name * @return Streams * @author Soner Sayakci */ public function setName(string $name): self { $this->name = $name; return $this; } /** * @return bool|null * @author Soner Sayakci */ public function getActive(): ?bool { return $this->active; } /** * @param bool $active * @return Streams * @author Soner Sayakci */ public function setActive(bool $active): self { $this->active = $active; return $this; } /** * @return int|null * @author Soner Sayakci */ public function getUserId(): ?int { return $this->userId; } /** * @param int $userId * @return Streams * @author Soner Sayakci */ public function setUserId(int $userId): self { $this->userId = $userId; return $this; } /** * @param User $user * @author Soner Sayakci */ public function setUser(User $user) { $this->user = $user; } /** * @return ArrayCollection * @author Soner Sayakci */ public function getEndpoints() { return $this->endpoints; } /** * @param ArrayCollection $endpoints * @return Streams * @author Soner Sayakci */ public function setEndpoints($endpoints): ArrayCollection { $this->endpoints = $endpoints; return $this; } /** * @return User * @author Soner Sayakci */ public function getUser() { return $this->user; } /** * @return string * @author Soner Sayakci */ public function getStreamKey(): string { return $this->streamKey; } /** * @param string $streamKey * @return Streams * @author Soner Sayakci */ public function setStreamKey(string $streamKey): Streams { $this->streamKey = $streamKey; return $this; } /** * @return mixed * @author Soner Sayakci */ public function getLive() { return $this->live; } /** * @param mixed $live * @author Soner Sayakci */ public function setLive($live): void { $this->live = $live; } /** * Specify data which should be serialized to JSON * @link http://php.net/manual/en/jsonserializable.jsonserialize.php * @return mixed data which can be serialized by json_encode, * which is a value of any type other than a resource. * @since 5.4.0 */ public function jsonSerialize() { return get_object_vars($this); } /** * @ORM\PostPersist() * @ORM\PostUpdate() * @author Soner Sayakci * @param LifecycleEventArgs $args * @throws \Doctrine\DBAL\DBALException */ public function updateConfig(LifecycleEventArgs $args): void { $args->getEntityManager()->getConnection()->insert('queue', ['task' => 'generate_config']); } /** * @ORM\PrePersist() * @author Soner Sayakci */ public function prePersist(): void { $this->streamKey = uniqid('', true); } /** * @ORM\PreUpdate() * @author Soner Sayakci */ public function preUpdate(): void { if (empty($this->streamKey)) { $this->prePersist(); } } }