ProfileColor.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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\ProfileColor\Entity;
  20. use App\Core\Entity;
  21. use DateTimeInterface;
  22. /**
  23. * For storing a profile Color
  24. *
  25. * @package GNUsocial
  26. * @category CoverPlugin
  27. *
  28. * @author Daniel Brandao <up201705812@fe.up.pt>
  29. * @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
  30. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  31. */
  32. class ProfileColor extends Entity
  33. {
  34. // {{{ Autocode
  35. // @codeCoverageIgnoreStart
  36. private int $actor_id;
  37. private ?string $background = null;
  38. private ?string $color = null;
  39. private DateTimeInterface $created;
  40. private DateTimeInterface $modified;
  41. public function setActorId(int $actor_id): self
  42. {
  43. $this->actor_id = $actor_id;
  44. return $this;
  45. }
  46. public function getActorId(): int
  47. {
  48. return $this->actor_id;
  49. }
  50. public function setBackground(?string $background): self
  51. {
  52. $this->background = $background;
  53. return $this;
  54. }
  55. public function getBackground(): ?string
  56. {
  57. return $this->background;
  58. }
  59. public function setColor(?string $color): self
  60. {
  61. $this->color = $color;
  62. return $this;
  63. }
  64. public function getColor(): ?string
  65. {
  66. return $this->color;
  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. public function setModified(DateTimeInterface $modified): self
  78. {
  79. $this->modified = $modified;
  80. return $this;
  81. }
  82. public function getModified(): DateTimeInterface
  83. {
  84. return $this->modified;
  85. }
  86. // @codeCoverageIgnoreEnd
  87. // }}} Autocode
  88. public static function schemaDef(): array
  89. {
  90. return [
  91. 'name' => 'profile_color',
  92. 'fields' => [
  93. 'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to actor table'],
  94. 'background' => ['type' => 'text', 'description' => 'color hex code'],
  95. 'color' => ['type' => 'text', 'description' => 'color hex code'],
  96. 'created' => ['type' => 'datetime', 'not null' => true, 'description' => 'date this record was created', 'default' => 'CURRENT_TIMESTAMP'],
  97. 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified', 'default' => 'CURRENT_TIMESTAMP'],
  98. ],
  99. 'primary key' => ['actor_id'],
  100. ];
  101. }
  102. }