app/Entity/Schema/ORM/IosApp.php line 13

Open in your IDE?
  1. <?php
  2. namespace Sq\Entity\Schema\ORM;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * IosApp.
  6.  */
  7. #[ORM\Entity]
  8. #[ORM\Table(name'ios_app')]
  9. #[ORM\UniqueConstraint(name'unique_ios'columns: ['ios_m_id''ios_device_token'])]
  10. class IosApp implements MobileAppInterface
  11. {
  12.     /**
  13.      * @var int
  14.      */
  15.     #[ORM\Column(name'ios_id'type'integer'nullablefalseoptions: ['unsigned' => true])]
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  18.     private $id;
  19.     /**
  20.      * @var Member|null
  21.      */
  22.     #[ORM\ManyToOne(targetEntityMember::class, inversedBy'iosApps')]
  23.     #[ORM\JoinColumn(name'ios_m_id'referencedColumnName'm_id'nullabletrue)]
  24.     private $member;
  25.     /**
  26.      *
  27.      * @var Organization|null
  28.      *
  29.      * @deprecated To be removed.
  30.      */
  31.     #[ORM\Column(name'ios_o_id'type'integer'nullabletrue)]
  32.     private $deprecatedOrganization;
  33.     /**
  34.      *
  35.      * @var User|null
  36.      */
  37.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'iosApps')]
  38.     #[ORM\JoinColumn(name'ios_u_id'referencedColumnName'u_id'nullabletrue)]
  39.     private $user;
  40.     /**
  41.      * @var string|null
  42.      */
  43.     #[ORM\Column(name'ios_device_token'type'string'length64nullabletrue)]
  44.     private $deviceToken;
  45.     /**
  46.      * @var string|null
  47.      */
  48.     #[ORM\Column(name'ios_endpoint_arn'type'string'length255nullabletrue)]
  49.     private $endpointArn;
  50.     /**
  51.      * @var \DateTime|null
  52.      */
  53.     #[ORM\Column(name'ios_token_first_added'type'datetime'nullabletrueoptions: ['default' => '0000-00-00 00:00:00'])]
  54.     private $firstConnectedTime;
  55.     /**
  56.      * @var \DateTime|null
  57.      */
  58.     #[ORM\Column(name'ios_token_last_updated'type'datetime'nullabletrueoptions: ['default' => '0000-00-00 00:00:00'])]
  59.     private $lastConnectedTime;
  60.     /**
  61.      * @var string|null
  62.      */
  63.     #[ORM\Column(name'ios_build'type'string'length10nullabletrue)]
  64.     private $build;
  65.     /**
  66.      * @var string|null
  67.      */
  68.     #[ORM\Column(name'ios_device_type'type'string'length64nullabletrue)]
  69.     private $deviceType;
  70.     /**
  71.      * @var string|null
  72.      */
  73.     #[ORM\Column(name'ios_device_name'type'string'length64nullabletrue)]
  74.     private $deviceName;
  75.     public function __construct(
  76.         User $user,
  77.         string $endpointArn,
  78.         string $apnDeviceToken,
  79.         int $buildCode,
  80.         ?string $deviceType null,
  81.         ?string $deviceName null,
  82.     ) {
  83.         $this->user $user;
  84.         $this->deviceToken $apnDeviceToken;
  85.         $this->endpointArn $endpointArn;
  86.         $this->build $buildCode;
  87.         $this->deviceType $deviceType;
  88.         $this->deviceName $deviceName;
  89.         $this->firstConnectedTime = new \DateTime();
  90.         $this->lastConnectedTime = new \DateTime();
  91.     }
  92.     public function getId(): ?int
  93.     {
  94.         return $this->id;
  95.     }
  96.     public function getMember(): ?Member
  97.     {
  98.         return $this->member;
  99.     }
  100.     public function getUser(): User
  101.     {
  102.         return $this->user;
  103.     }
  104.     public function getDeviceToken(): string
  105.     {
  106.         return $this->deviceToken;
  107.     }
  108.     public function getEndpointArn(): ?string
  109.     {
  110.         return $this->endpointArn;
  111.     }
  112.     public function updateEndpointArn(?string $endpointArn): static
  113.     {
  114.         $this->endpointArn $endpointArn;
  115.         $this->lastConnectedTime = new \DateTime();
  116.         return $this;
  117.     }
  118.     public function getFirstConnectedTime(): \DateTimeInterface
  119.     {
  120.         return $this->firstConnectedTime;
  121.     }
  122.     public function getLastConnectedTime(): \DateTimeInterface
  123.     {
  124.         return $this->lastConnectedTime;
  125.     }
  126.     public function getBuildNumber(): int
  127.     {
  128.         return (int) $this->build;
  129.     }
  130.     public function updateBuildNumber(int $buildNumber): static
  131.     {
  132.         $this->build '' $buildNumber;
  133.         return $this;
  134.     }
  135.     public function getDeviceType(): ?string
  136.     {
  137.         return $this->deviceType;
  138.     }
  139.     public function getDeviceName(): ?string
  140.     {
  141.         return $this->deviceName;
  142.     }
  143.     public function updateDeviceName(string $deviceName): static
  144.     {
  145.         $this->deviceName $deviceName;
  146.         return $this;
  147.     }
  148.     public function isConnected(): bool
  149.     {
  150.         return $this->endpointArn !== null;
  151.     }
  152.     /**
  153.      * Check if they have a valid connected app (with notifications still working), and the app is recent enough to support video & carousel posts.
  154.      *
  155.      * @return bool
  156.      */
  157.     public function isVideoCarouselSupported(): bool
  158.     {
  159.         global $arr_config;
  160.         return $this->build >= $arr_config['ios_video_carousel_min_build'] && $this->endpointArn != "";
  161.     }
  162.     /**
  163.      * Check if they have a valid connected app (with notifications still working), and the app is recent enough to support Generic Profiles.
  164.      *
  165.      * @return bool
  166.      */
  167.     public function isGenericProfileSupported(): bool
  168.     {
  169.         global $arr_config;
  170.         return $this->build >= $arr_config['ios_generic_profiles_min_build'] && $this->endpointArn != "";
  171.     }
  172. }