ActorCircleSubscription.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. declare(strict_types = 1);
  3. // {{{ License
  4. // This file is part of GNU social - https://www.gnu.org/software/social
  5. //
  6. // GNU social is free software: you can redistribute it and/or modify
  7. // it under the terms of the GNU Affero General Public License as published by
  8. // the Free Software Foundation, either version 3 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // GNU social is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU Affero General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU Affero General Public License
  17. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  18. // }}}
  19. namespace Component\Circle\Entity;
  20. use App\Core\Entity;
  21. use DateTimeInterface;
  22. /**
  23. * Entity for actor circle subscriptions
  24. * This entity only makes sense when considered with the ActorCircle entity.
  25. * Because you can only subscribe a Circle that exists.
  26. *
  27. * @category DB
  28. * @package GNUsocial
  29. *
  30. * @author Zach Copley <zach@status.net>
  31. * @copyright 2010 StatusNet Inc.
  32. * @author Mikael Nordfeldth <mmn@hethane.se>
  33. * @copyright 2009-2014 Free Software Foundation, Inc http://www.fsf.org
  34. * @author Hugo Sales <hugo@hsal.es>
  35. * @author Diogo Peralta Cordeiro <@diogo.site>
  36. * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org
  37. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  38. */
  39. class ActorCircleSubscription extends Entity
  40. {
  41. // {{{ Autocode
  42. // @codeCoverageIgnoreStart
  43. private int $actor_id;
  44. private int $circle_id;
  45. private DateTimeInterface $created;
  46. private DateTimeInterface $modified;
  47. public function setActorId(int $actor_id): self
  48. {
  49. $this->actor_id = $actor_id;
  50. return $this;
  51. }
  52. public function getActorId(): int
  53. {
  54. return $this->actor_id;
  55. }
  56. public function setCircleId(int $circle_id): self
  57. {
  58. $this->circle_id = $circle_id;
  59. return $this;
  60. }
  61. public function getCircleId(): int
  62. {
  63. return $this->circle_id;
  64. }
  65. public function setCreated(DateTimeInterface $created): self
  66. {
  67. $this->created = $created;
  68. return $this;
  69. }
  70. public function getCreated(): DateTimeInterface
  71. {
  72. return $this->created;
  73. }
  74. public function setModified(DateTimeInterface $modified): self
  75. {
  76. $this->modified = $modified;
  77. return $this;
  78. }
  79. public function getModified(): DateTimeInterface
  80. {
  81. return $this->modified;
  82. }
  83. // @codeCoverageIgnoreEnd
  84. // }}} Autocode
  85. public static function schemaDef(): array
  86. {
  87. return [
  88. 'name' => 'actor_circle_subscription',
  89. 'fields' => [
  90. 'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_circle_subscription_actor_id_fkey', 'not null' => true, 'description' => 'foreign key to actor table'],
  91. // An actor subscribes many circles; A Circle is subscribed by many actors.
  92. 'circle_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'ActorCircle.id', 'multiplicity' => 'one to many', 'name' => 'actor_circle_subscription_actor_circle_fkey', 'not null' => true, 'description' => 'foreign key to actor_circle'],
  93. 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
  94. 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
  95. ],
  96. 'primary key' => ['circle_id', 'actor_id'],
  97. 'indexes' => [
  98. 'actor_circle_subscription_actor_id_idx' => ['actor_id'],
  99. 'actor_circle_subscription_created_idx' => ['created'],
  100. ],
  101. ];
  102. }
  103. }