ProfileColor.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 Plugin\ProfileColor\Entity;
  19. use App\Core\Entity;
  20. use DateTimeInterface;
  21. /**
  22. * For storing a profile Color
  23. *
  24. * @package GNUsocial
  25. * @category CoverPlugin
  26. *
  27. * @author Daniel Brandao <up201705812@fe.up.pt>
  28. * @copyright 2020 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 ProfileColor extends Entity
  32. {
  33. // {{{ Autocode
  34. // @codeCoverageIgnoreStart
  35. private int $gsactor_id;
  36. private string $color;
  37. private \DateTimeInterface $created;
  38. private \DateTimeInterface $modified;
  39. public function setGSActorId(int $gsactor_id): self
  40. {
  41. $this->gsactor_id = $gsactor_id;
  42. return $this;
  43. }
  44. public function getGSActorId(): int
  45. {
  46. return $this->gsactor_id;
  47. }
  48. public function setColor(string $color): self
  49. {
  50. $this->color = $color;
  51. return $this;
  52. }
  53. public function getColor(): string
  54. {
  55. return $this->color;
  56. }
  57. public function setCreated(DateTimeInterface $created): self
  58. {
  59. $this->created = $created;
  60. return $this;
  61. }
  62. public function getCreated(): DateTimeInterface
  63. {
  64. return $this->created;
  65. }
  66. public function setModified(DateTimeInterface $modified): self
  67. {
  68. $this->modified = $modified;
  69. return $this;
  70. }
  71. public function getModified(): DateTimeInterface
  72. {
  73. return $this->modified;
  74. }
  75. // @codeCoverageIgnoreEnd
  76. // }}} Autocode
  77. public static function schemaDef(): array
  78. {
  79. return [
  80. 'name' => 'profile_color',
  81. 'fields' => [
  82. 'gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to gsactor table'],
  83. 'color' => ['type' => 'text', 'not null' => true, 'description' => 'color hex code'],
  84. 'created' => ['type' => 'datetime', 'not null' => true, 'description' => 'date this record was created', 'default' => 'CURRENT_TIMESTAMP'],
  85. 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified', 'default' => 'CURRENT_TIMESTAMP'],
  86. ],
  87. 'primary key' => ['gsactor_id'],
  88. ];
  89. }
  90. }