ForeignSubscription.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. // {{{ License
  3. // This file is part of GNU social - https://www.gnu.org/software/social
  4. //
  5. // GNU social is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU Affero General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // GNU social is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU Affero General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Affero General Public License
  16. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  17. // }}}
  18. namespace Component\Bridge\Entity;
  19. use DateTimeInterface;
  20. /**
  21. * Entity for user's foreign subscriptions
  22. *
  23. * @category DB
  24. * @package GNUsocial
  25. *
  26. * @author Zach Copley <zach@status.net>
  27. * @copyright 2010 StatusNet Inc.
  28. * @author Mikael Nordfeldth <mmn@hethane.se>
  29. * @copyright 2009-2014 Free Software Foundation, Inc http://www.fsf.org
  30. * @author Hugo Sales <hugo@fc.up.pt>
  31. * @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
  32. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  33. */
  34. class ForeignSubscription
  35. {
  36. // {{{ Autocode
  37. private int $service;
  38. private int $subscriber;
  39. private int $subscribed;
  40. private DateTimeInterface $created;
  41. public function setService(int $service): self
  42. {
  43. $this->service = $service;
  44. return $this;
  45. }
  46. public function getService(): int
  47. {
  48. return $this->service;
  49. }
  50. public function setSubscriber(int $subscriber): self
  51. {
  52. $this->subscriber = $subscriber;
  53. return $this;
  54. }
  55. public function getSubscriber(): int
  56. {
  57. return $this->subscriber;
  58. }
  59. public function setSubscribed(int $subscribed): self
  60. {
  61. $this->subscribed = $subscribed;
  62. return $this;
  63. }
  64. public function getSubscribed(): int
  65. {
  66. return $this->subscribed;
  67. }
  68. public function setCreated(DateTimeInterface $created): self
  69. {
  70. $this->created = $created;
  71. return $this;
  72. }
  73. public function getCreated(): DateTimeInterface
  74. {
  75. return $this->created;
  76. }
  77. // }}} Autocode
  78. public static function schemaDef(): array
  79. {
  80. return [
  81. 'name' => 'foreign_subscription',
  82. 'fields' => [
  83. 'service' => ['type' => 'int', 'not null' => true, 'description' => 'service where relationship happens'],
  84. 'subscriber' => ['type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'subscriber on foreign service'],
  85. 'subscribed' => ['type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'subscribed user'],
  86. 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
  87. ],
  88. 'primary key' => ['service', 'subscriber', 'subscribed'],
  89. 'foreign keys' => [
  90. 'foreign_subscription_service_fkey' => ['foreign_service', ['service' => 'id']],
  91. 'foreign_subscription_subscriber_fkey' => ['foreign_user', ['subscriber' => 'id', 'service' => 'service']],
  92. 'foreign_subscription_subscribed_fkey' => ['foreign_user', ['subscribed' => 'id', 'service' => 'service']],
  93. ],
  94. 'indexes' => [
  95. 'foreign_subscription_subscriber_idx' => ['service', 'subscriber'],
  96. 'foreign_subscription_subscribed_idx' => ['service', 'subscribed'],
  97. ],
  98. ];
  99. }
  100. }