BundleCollectionEntry.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 Plugin\Bundles\Entity;
  20. use App\Core\Entity;
  21. /**
  22. * BlogCollectionEntry Entity
  23. *
  24. * @package GNUsocial
  25. * @category BlogCollectionsPlugin
  26. *
  27. * @author Eliseu Amaro <mail@eliseuama.ro>
  28. * @copyright 2022 Free Software Foundation, Inc http://www.fsf.org
  29. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  30. */
  31. class BundleCollectionEntry extends Entity
  32. {
  33. // {{{ Autocode
  34. // @codeCoverageIgnoreStart
  35. private int $id;
  36. private int $note_id;
  37. private int $blog_collection_id;
  38. public function setId(int $id): self
  39. {
  40. $this->id = $id;
  41. return $this;
  42. }
  43. public function getId(): int
  44. {
  45. return $this->id;
  46. }
  47. public function setNoteId(int $note_id): self
  48. {
  49. $this->note_id = $note_id;
  50. return $this;
  51. }
  52. public function getNoteId(): int
  53. {
  54. return $this->note_id;
  55. }
  56. public function setBlogCollectionId(int $blog_collection_id): self
  57. {
  58. $this->blog_collection_id = $blog_collection_id;
  59. return $this;
  60. }
  61. public function getBlogCollectionId(): int
  62. {
  63. return $this->blog_collection_id;
  64. }
  65. // @codeCoverageIgnoreEnd
  66. // }}} Autocode
  67. public static function schemaDef(): array
  68. {
  69. return [
  70. 'name' => 'blog_collection_entry',
  71. 'fields' => [
  72. 'id' => ['type' => 'serial', 'not null' => true, 'description' => 'unique identifier'],
  73. 'note_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Note.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'Foreign key to note table, since a Blog entry is really just a Note with a higher text limit'],
  74. 'blog_collection_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'BlogCollection.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'Foreign key to blog_collection table, indicates what category/collection this Blog entry is a part of'],
  75. ],
  76. 'primary key' => ['id'],
  77. 'foreign keys' => [
  78. 'note_id_to_id_fkey' => ['note', ['note_id' => 'id']],
  79. 'blog_collection_id_to_id_fkey' => ['blog_collection', ['blog_collection_id' => 'id']],
  80. ],
  81. ];
  82. }
  83. }