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

Open in your IDE?
  1. <?php
  2. namespace Sq\Entity\Schema\ORM;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * AndroidApp.
  6.  */
  7. #[ORM\Entity]
  8. #[ORM\Table(name'android_app')]
  9. #[ORM\UniqueConstraint(name'unique_android'columns: ['android_m_id''android_app_uuid'])]
  10. class AndroidApp implements MobileAppInterface
  11. {
  12.     /**
  13.      * @var int
  14.      */
  15.     #[ORM\Column(name'android_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'androidApps')]
  23.     #[ORM\JoinColumn(name'android_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'android_o_id'type'integer'nullabletrue)]
  32.     private $deprecatedOrganization;
  33.     /**
  34.      *
  35.      * @var User|null
  36.      */
  37.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'androidApps')]
  38.     #[ORM\JoinColumn(name'android_u_id'referencedColumnName'u_id'nullabletrue)]
  39.     private $user;
  40.     /**
  41.      * @var string|null
  42.      */
  43.     #[ORM\Column(name'android_firebase_token'type'string'length255nullabletrue)]
  44.     private $firebaseToken;
  45.     /**
  46.      * @var string|null
  47.      */
  48.     #[ORM\Column(name'android_app_uuid'type'string'length36nullabletrue)]
  49.     private $uuid;
  50.     /**
  51.      * @var int
  52.      */
  53.     #[ORM\Column(name'android_app_version_code'type'integer'nullablefalseoptions: ['unsigned' => true])]
  54.     private $versionCode;
  55.     /**
  56.      * @var \DateTimeInterface|null
  57.      */
  58.     #[ORM\Column(name'android_token_first_added'type'datetime'nullabletrueoptions: ['default' => '0000-00-00 00:00:00'])]
  59.     private $firstConnectedTime;
  60.     /**
  61.      * @var \DateTimeInterface|null
  62.      */
  63.     #[ORM\Column(name'android_token_last_updated'type'datetime'nullabletrueoptions: ['default' => '0000-00-00 00:00:00'])]
  64.     private $lastConnectedTime;
  65.     /**
  66.      * @var string|null
  67.      */
  68.     #[ORM\Column(name'android_device_type'type'string'length191nullabletrue)]
  69.     private $deviceType;
  70.     /**
  71.      * @var string|null
  72.      */
  73.     #[ORM\Column(name'android_device_name'type'string'length191nullabletrue)]
  74.     private $deviceName;
  75.     public function __construct(
  76.         User $user,
  77.         string $firebaseToken,
  78.         string $uuid,
  79.         int $buildCode,
  80.         ?string $deviceType null,
  81.         ?string $deviceName null,
  82.     ) {
  83.         $this->user $user;
  84.         $this->firebaseToken $firebaseToken;
  85.         $this->uuid $uuid;
  86.         $this->versionCode $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 getFirebaseToken(): ?string
  105.     {
  106.         return $this->firebaseToken;
  107.     }
  108.     public function updateFirebaseToken(?string $token): static
  109.     {
  110.         $this->firebaseToken $token;
  111.         $this->lastConnectedTime = new \DateTime();
  112.         return $this;
  113.     }
  114.     public function getUuid(): string
  115.     {
  116.         return $this->uuid;
  117.     }
  118.     public function getBuildNumber(): int
  119.     {
  120.         return $this->versionCode;
  121.     }
  122.     public function updateBuildNumber(int $buildNumber): static
  123.     {
  124.         $this->versionCode $buildNumber;
  125.         return $this;
  126.     }
  127.     public function getFirstConnectedTime(): \DateTimeInterface
  128.     {
  129.         return $this->firstConnectedTime;
  130.     }
  131.     public function getLastConnectedTime(): \DateTimeInterface
  132.     {
  133.         return $this->lastConnectedTime;
  134.     }
  135.     public function isVideoCarouselSupported(): bool
  136.     {
  137.         global $arr_config;
  138.         return $this->versionCode >= $arr_config['android_video_carousel_min_build'] && $this->isConnected();
  139.     }
  140.     /**
  141.      * Check if they have a valid connected app (with notifications still working), and the app is recent enough to support Generic Profiles.
  142.      *
  143.      * @return bool
  144.      */
  145.     public function isGenericProfileSupported(): bool
  146.     {
  147.         return false// TODO-GENERIC_PROFILES - once we have an Android app that supports Generic Profiles, update this function AND the build number in config
  148.         global $arr_config;
  149.         return $this->versionCode >= $arr_config['android_generic_profiles_min_build'] && $this->isConnected();
  150.     }
  151.     public function getDeviceType(): ?string
  152.     {
  153.         return $this->deviceType;
  154.     }
  155.     public function getDeviceName(): ?string
  156.     {
  157.         return $this->deviceName;
  158.     }
  159.     public function updateDeviceName(string $deviceName): static
  160.     {
  161.         $this->deviceName $deviceName;
  162.         return $this;
  163.     }
  164.     public function isConnected(): bool
  165.     {
  166.         return $this->firebaseToken !== null;
  167.     }
  168. }