2016-09-02 00:34:08 +00:00
|
|
|
<?php
|
2018-08-04 22:05:14 +00:00
|
|
|
namespace App\Entity;
|
2016-09-02 00:34:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Station streamers (DJ accounts) allowed to broadcast to a station.
|
|
|
|
*
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Table(name="station_streamers")
|
|
|
|
* @ORM\Entity(repositoryClass="App\Entity\Repository\StationStreamerRepository")
|
2016-09-02 00:34:08 +00:00
|
|
|
* @HasLifecycleCallbacks
|
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
class StationStreamer
|
2016-09-02 00:34:08 +00:00
|
|
|
{
|
2018-04-06 21:29:27 +00:00
|
|
|
use Traits\TruncateStrings;
|
|
|
|
|
2016-09-02 00:34:08 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="id", type="integer")
|
|
|
|
* @ORM\Id
|
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY")
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var int
|
2016-09-02 00:34:08 +00:00
|
|
|
*/
|
|
|
|
protected $id;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="station_id", type="integer")
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var int
|
|
|
|
*/
|
2016-09-02 00:34:08 +00:00
|
|
|
protected $station_id;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\ManyToOne(targetEntity="Station", inversedBy="streamers")
|
2017-08-17 18:28:48 +00:00
|
|
|
* @JoinColumns({
|
|
|
|
* @JoinColumn(name="station_id", referencedColumnName="id", onDelete="CASCADE")
|
|
|
|
* })
|
|
|
|
* @var Station
|
|
|
|
*/
|
|
|
|
protected $station;
|
|
|
|
|
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="streamer_username", type="string", length=50, nullable=false)
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var string
|
|
|
|
*/
|
2016-09-02 00:34:08 +00:00
|
|
|
protected $streamer_username;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="streamer_password", type="string", length=50, nullable=false)
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var string
|
|
|
|
*/
|
2016-09-02 00:34:08 +00:00
|
|
|
protected $streamer_password;
|
|
|
|
|
2018-02-03 21:54:12 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="display_name", type="string", length=255, nullable=true)
|
2018-02-03 21:54:12 +00:00
|
|
|
* @var string|null
|
|
|
|
*/
|
|
|
|
protected $display_name;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="comments", type="text", nullable=true)
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var string|null
|
|
|
|
*/
|
2016-09-02 00:34:08 +00:00
|
|
|
protected $comments;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="is_active", type="boolean", nullable=false)
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var bool
|
|
|
|
*/
|
2016-09-02 00:34:08 +00:00
|
|
|
protected $is_active;
|
|
|
|
|
2018-10-27 00:14:32 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="reactivate_at", type="integer", nullable=true)
|
2018-10-27 00:14:32 +00:00
|
|
|
* @var int|null
|
|
|
|
*/
|
|
|
|
protected $reactivate_at;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function __construct(Station $station)
|
|
|
|
{
|
|
|
|
$this->station = $station;
|
|
|
|
|
|
|
|
$this->is_active = true;
|
|
|
|
}
|
|
|
|
|
2016-09-02 00:34:08 +00:00
|
|
|
/**
|
2017-08-17 18:28:48 +00:00
|
|
|
* @return int
|
2016-09-02 00:34:08 +00:00
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getId(): int
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Station
|
|
|
|
*/
|
|
|
|
public function getStation(): Station
|
|
|
|
{
|
|
|
|
return $this->station;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getStreamerUsername(): string
|
|
|
|
{
|
|
|
|
return $this->streamer_username;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $streamer_username
|
|
|
|
*/
|
|
|
|
public function setStreamerUsername(string $streamer_username)
|
|
|
|
{
|
2018-04-06 21:29:27 +00:00
|
|
|
$this->streamer_username = $this->_truncateString($streamer_username, 50);
|
2017-08-17 18:28:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getStreamerPassword(): string
|
|
|
|
{
|
|
|
|
return $this->streamer_password;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $streamer_password
|
|
|
|
*/
|
|
|
|
public function setStreamerPassword(string $streamer_password)
|
|
|
|
{
|
2018-04-06 21:29:27 +00:00
|
|
|
$this->streamer_password = $this->_truncateString($streamer_password, 50);
|
2017-08-17 18:28:48 +00:00
|
|
|
}
|
|
|
|
|
2018-02-03 21:54:12 +00:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getDisplayName(): string
|
|
|
|
{
|
|
|
|
return (!empty($this->display_name))
|
|
|
|
? $this->display_name
|
|
|
|
:$this->streamer_username;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param null|string $display_name
|
|
|
|
*/
|
|
|
|
public function setDisplayName(?string $display_name): void
|
|
|
|
{
|
2018-04-06 21:29:27 +00:00
|
|
|
$this->display_name = $this->_truncateString($display_name);
|
2018-02-03 21:54:12 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return null|string
|
|
|
|
*/
|
|
|
|
public function getComments(): ?string
|
|
|
|
{
|
|
|
|
return $this->comments;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param null|string $comments
|
|
|
|
*/
|
|
|
|
public function setComments(string $comments = null)
|
|
|
|
{
|
|
|
|
$this->comments = $comments;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function getIsActive(): bool
|
|
|
|
{
|
|
|
|
return $this->is_active;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param bool $is_active
|
|
|
|
*/
|
|
|
|
public function setIsActive(bool $is_active)
|
|
|
|
{
|
|
|
|
$this->is_active = $is_active;
|
2018-10-27 00:23:22 +00:00
|
|
|
|
|
|
|
// Automatically set the "reactivate_at" flag to null if the DJ is for any reason reactivated.
|
|
|
|
if (true === $is_active) {
|
|
|
|
$this->reactivate_at = null;
|
|
|
|
}
|
2017-08-17 18:28:48 +00:00
|
|
|
}
|
2018-10-27 00:14:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return int|null
|
|
|
|
*/
|
|
|
|
public function getReactivateAt(): ?int
|
|
|
|
{
|
|
|
|
return $this->reactivate_at;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int|null $reactivate_at
|
|
|
|
*/
|
|
|
|
public function setReactivateAt(?int $reactivate_at)
|
|
|
|
{
|
|
|
|
$this->reactivate_at = $reactivate_at;
|
|
|
|
}
|
2018-10-27 00:23:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Deactivate this streamer for the specified period of time.
|
|
|
|
*
|
|
|
|
* @param int $seconds
|
|
|
|
*/
|
|
|
|
public function deactivateFor(int $seconds)
|
|
|
|
{
|
|
|
|
$this->is_active = false;
|
|
|
|
$this->reactivate_at = time()+$seconds;
|
|
|
|
}
|
2018-08-04 22:05:14 +00:00
|
|
|
}
|