aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Entity
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity')
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php169
-rw-r--r--src/Wallabag/CoreBundle/Entity/SiteCredential.php188
-rw-r--r--src/Wallabag/CoreBundle/Entity/Tag.php2
-rw-r--r--src/Wallabag/CoreBundle/Entity/TaggingRule.php4
4 files changed, 317 insertions, 46 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index 7276b437..61d01bdc 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -5,14 +5,15 @@ namespace Wallabag\CoreBundle\Entity;
5use Doctrine\Common\Collections\ArrayCollection; 5use Doctrine\Common\Collections\ArrayCollection;
6use Doctrine\ORM\Mapping as ORM; 6use Doctrine\ORM\Mapping as ORM;
7use Hateoas\Configuration\Annotation as Hateoas; 7use Hateoas\Configuration\Annotation as Hateoas;
8use JMS\Serializer\Annotation\Groups;
9use JMS\Serializer\Annotation\XmlRoot;
10use JMS\Serializer\Annotation\Exclude; 8use JMS\Serializer\Annotation\Exclude;
11use JMS\Serializer\Annotation\VirtualProperty; 9use JMS\Serializer\Annotation\Groups;
12use JMS\Serializer\Annotation\SerializedName; 10use JMS\Serializer\Annotation\SerializedName;
11use JMS\Serializer\Annotation\VirtualProperty;
12use JMS\Serializer\Annotation\XmlRoot;
13use Symfony\Component\Validator\Constraints as Assert; 13use Symfony\Component\Validator\Constraints as Assert;
14use Wallabag\UserBundle\Entity\User;
15use Wallabag\AnnotationBundle\Entity\Annotation; 14use Wallabag\AnnotationBundle\Entity\Annotation;
15use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
16use Wallabag\UserBundle\Entity\User;
16 17
17/** 18/**
18 * Entry. 19 * Entry.
@@ -32,6 +33,8 @@ use Wallabag\AnnotationBundle\Entity\Annotation;
32 */ 33 */
33class Entry 34class Entry
34{ 35{
36 use EntityTimestampsTrait;
37
35 /** @Serializer\XmlAttribute */ 38 /** @Serializer\XmlAttribute */
36 /** 39 /**
37 * @var int 40 * @var int
@@ -122,6 +125,24 @@ class Entry
122 private $updatedAt; 125 private $updatedAt;
123 126
124 /** 127 /**
128 * @var \DateTime
129 *
130 * @ORM\Column(name="published_at", type="datetime", nullable=true)
131 *
132 * @Groups({"entries_for_user", "export_all"})
133 */
134 private $publishedAt;
135
136 /**
137 * @var array
138 *
139 * @ORM\Column(name="published_by", type="array", nullable=true)
140 *
141 * @Groups({"entries_for_user", "export_all"})
142 */
143 private $publishedBy;
144
145 /**
125 * @ORM\OneToMany(targetEntity="Wallabag\AnnotationBundle\Entity\Annotation", mappedBy="entry", cascade={"persist", "remove"}) 146 * @ORM\OneToMany(targetEntity="Wallabag\AnnotationBundle\Entity\Annotation", mappedBy="entry", cascade={"persist", "remove"})
126 * @ORM\JoinTable 147 * @ORM\JoinTable
127 * 148 *
@@ -175,22 +196,22 @@ class Entry
175 private $previewPicture; 196 private $previewPicture;
176 197
177 /** 198 /**
178 * @var bool 199 * @var string
179 * 200 *
180 * @ORM\Column(name="is_public", type="boolean", nullable=true, options={"default" = false}) 201 * @ORM\Column(name="http_status", type="string", length=3, nullable=true)
181 * 202 *
182 * @Groups({"export_all"}) 203 * @Groups({"entries_for_user", "export_all"})
183 */ 204 */
184 private $isPublic; 205 private $httpStatus;
185 206
186 /** 207 /**
187 * @var string 208 * @var array
188 * 209 *
189 * @ORM\Column(name="http_status", type="string", length=3, nullable=true) 210 * @ORM\Column(name="headers", type="array", nullable=true)
190 * 211 *
191 * @Groups({"entries_for_user", "export_all"}) 212 * @Groups({"entries_for_user", "export_all"})
192 */ 213 */
193 private $httpStatus; 214 private $headers;
194 215
195 /** 216 /**
196 * @Exclude 217 * @Exclude
@@ -455,19 +476,6 @@ class Entry
455 } 476 }
456 477
457 /** 478 /**
458 * @ORM\PrePersist
459 * @ORM\PreUpdate
460 */
461 public function timestamps()
462 {
463 if (is_null($this->createdAt)) {
464 $this->createdAt = new \DateTime();
465 }
466
467 $this->updatedAt = new \DateTime();
468 }
469
470 /**
471 * @return ArrayCollection<Annotation> 479 * @return ArrayCollection<Annotation>
472 */ 480 */
473 public function getAnnotations() 481 public function getAnnotations()
@@ -532,23 +540,7 @@ class Entry
532 } 540 }
533 541
534 /** 542 /**
535 * @return bool 543 * @return ArrayCollection
536 */
537 public function isPublic()
538 {
539 return $this->isPublic;
540 }
541
542 /**
543 * @param bool $isPublic
544 */
545 public function setIsPublic($isPublic)
546 {
547 $this->isPublic = $isPublic;
548 }
549
550 /**
551 * @return ArrayCollection<Tag>
552 */ 544 */
553 public function getTags() 545 public function getTags()
554 { 546 {
@@ -591,6 +583,11 @@ class Entry
591 $tag->addEntry($this); 583 $tag->addEntry($this);
592 } 584 }
593 585
586 /**
587 * Remove the given tag from the entry (if the tag is associated).
588 *
589 * @param Tag $tag
590 */
594 public function removeTag(Tag $tag) 591 public function removeTag(Tag $tag)
595 { 592 {
596 if (!$this->tags->contains($tag)) { 593 if (!$this->tags->contains($tag)) {
@@ -602,6 +599,17 @@ class Entry
602 } 599 }
603 600
604 /** 601 /**
602 * Remove all assigned tags from the entry.
603 */
604 public function removeAllTags()
605 {
606 foreach ($this->tags as $tag) {
607 $this->tags->removeElement($tag);
608 $tag->removeEntry($this);
609 }
610 }
611
612 /**
605 * Set previewPicture. 613 * Set previewPicture.
606 * 614 *
607 * @param string $previewPicture 615 * @param string $previewPicture
@@ -683,7 +691,22 @@ class Entry
683 } 691 }
684 692
685 /** 693 /**
686 * @return int 694 * Used in the entries filter so it's more explicit for the end user than the uid.
695 * Also used in the API.
696 *
697 * @VirtualProperty
698 * @SerializedName("is_public")
699 * @Groups({"entries_for_user"})
700 *
701 * @return bool
702 */
703 public function isPublic()
704 {
705 return null !== $this->uid;
706 }
707
708 /**
709 * @return string
687 */ 710 */
688 public function getHttpStatus() 711 public function getHttpStatus()
689 { 712 {
@@ -691,7 +714,7 @@ class Entry
691 } 714 }
692 715
693 /** 716 /**
694 * @param int $httpStatus 717 * @param string $httpStatus
695 * 718 *
696 * @return Entry 719 * @return Entry
697 */ 720 */
@@ -701,4 +724,64 @@ class Entry
701 724
702 return $this; 725 return $this;
703 } 726 }
727
728 /**
729 * @return \Datetime
730 */
731 public function getPublishedAt()
732 {
733 return $this->publishedAt;
734 }
735
736 /**
737 * @param \Datetime $publishedAt
738 *
739 * @return Entry
740 */
741 public function setPublishedAt(\Datetime $publishedAt)
742 {
743 $this->publishedAt = $publishedAt;
744
745 return $this;
746 }
747
748 /**
749 * @return array
750 */
751 public function getPublishedBy()
752 {
753 return $this->publishedBy;
754 }
755
756 /**
757 * @param array $publishedBy
758 *
759 * @return Entry
760 */
761 public function setPublishedBy($publishedBy)
762 {
763 $this->publishedBy = $publishedBy;
764
765 return $this;
766 }
767
768 /**
769 * @return array
770 */
771 public function getHeaders()
772 {
773 return $this->headers;
774 }
775
776 /**
777 * @param array $headers
778 *
779 * @return Entry
780 */
781 public function setHeaders($headers)
782 {
783 $this->headers = $headers;
784
785 return $this;
786 }
704} 787}
diff --git a/src/Wallabag/CoreBundle/Entity/SiteCredential.php b/src/Wallabag/CoreBundle/Entity/SiteCredential.php
new file mode 100644
index 00000000..ac714359
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Entity/SiteCredential.php
@@ -0,0 +1,188 @@
1<?php
2
3namespace Wallabag\CoreBundle\Entity;
4
5use Doctrine\ORM\Mapping as ORM;
6use Symfony\Component\Validator\Constraints as Assert;
7use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
8use Wallabag\UserBundle\Entity\User;
9
10/**
11 * SiteCredential.
12 *
13 * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\SiteCredentialRepository")
14 * @ORM\Table(name="`site_credential`")
15 * @ORM\HasLifecycleCallbacks()
16 */
17class SiteCredential
18{
19 use EntityTimestampsTrait;
20
21 /**
22 * @var int
23 *
24 * @ORM\Column(name="id", type="integer")
25 * @ORM\Id
26 * @ORM\GeneratedValue(strategy="AUTO")
27 */
28 private $id;
29
30 /**
31 * @var string
32 *
33 * @Assert\NotBlank()
34 * @Assert\Length(max=255)
35 * @ORM\Column(name="host", type="string", length=255)
36 */
37 private $host;
38
39 /**
40 * @var string
41 *
42 * @Assert\NotBlank()
43 * @ORM\Column(name="username", type="text")
44 */
45 private $username;
46
47 /**
48 * @var string
49 *
50 * @Assert\NotBlank()
51 * @ORM\Column(name="password", type="text")
52 */
53 private $password;
54
55 /**
56 * @var \DateTime
57 *
58 * @ORM\Column(name="createdAt", type="datetime")
59 */
60 private $createdAt;
61
62 /**
63 * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="siteCredentials")
64 */
65 private $user;
66
67 /*
68 * @param User $user
69 */
70 public function __construct(User $user)
71 {
72 $this->user = $user;
73 }
74
75 /**
76 * Get id.
77 *
78 * @return int
79 */
80 public function getId()
81 {
82 return $this->id;
83 }
84
85 /**
86 * Set host.
87 *
88 * @param string $host
89 *
90 * @return SiteCredential
91 */
92 public function setHost($host)
93 {
94 $this->host = $host;
95
96 return $this;
97 }
98
99 /**
100 * Get host.
101 *
102 * @return string
103 */
104 public function getHost()
105 {
106 return $this->host;
107 }
108
109 /**
110 * Set username.
111 *
112 * @param string $username
113 *
114 * @return SiteCredential
115 */
116 public function setUsername($username)
117 {
118 $this->username = $username;
119
120 return $this;
121 }
122
123 /**
124 * Get username.
125 *
126 * @return string
127 */
128 public function getUsername()
129 {
130 return $this->username;
131 }
132
133 /**
134 * Set password.
135 *
136 * @param string $password
137 *
138 * @return SiteCredential
139 */
140 public function setPassword($password)
141 {
142 $this->password = $password;
143
144 return $this;
145 }
146
147 /**
148 * Get password.
149 *
150 * @return string
151 */
152 public function getPassword()
153 {
154 return $this->password;
155 }
156
157 /**
158 * Set createdAt.
159 *
160 * @param \DateTime $createdAt
161 *
162 * @return SiteCredential
163 */
164 public function setCreatedAt($createdAt)
165 {
166 $this->createdAt = $createdAt;
167
168 return $this;
169 }
170
171 /**
172 * Get createdAt.
173 *
174 * @return \DateTime
175 */
176 public function getCreatedAt()
177 {
178 return $this->createdAt;
179 }
180
181 /**
182 * @return User
183 */
184 public function getUser()
185 {
186 return $this->user;
187 }
188}
diff --git a/src/Wallabag/CoreBundle/Entity/Tag.php b/src/Wallabag/CoreBundle/Entity/Tag.php
index 4b480ff1..c19023af 100644
--- a/src/Wallabag/CoreBundle/Entity/Tag.php
+++ b/src/Wallabag/CoreBundle/Entity/Tag.php
@@ -4,9 +4,9 @@ namespace Wallabag\CoreBundle\Entity;
4 4
5use Doctrine\Common\Collections\ArrayCollection; 5use Doctrine\Common\Collections\ArrayCollection;
6use Doctrine\ORM\Mapping as ORM; 6use Doctrine\ORM\Mapping as ORM;
7use Gedmo\Mapping\Annotation as Gedmo;
7use JMS\Serializer\Annotation\ExclusionPolicy; 8use JMS\Serializer\Annotation\ExclusionPolicy;
8use JMS\Serializer\Annotation\Expose; 9use JMS\Serializer\Annotation\Expose;
9use Gedmo\Mapping\Annotation as Gedmo;
10use JMS\Serializer\Annotation\XmlRoot; 10use JMS\Serializer\Annotation\XmlRoot;
11 11
12/** 12/**
diff --git a/src/Wallabag/CoreBundle/Entity/TaggingRule.php b/src/Wallabag/CoreBundle/Entity/TaggingRule.php
index 72651b19..84e11e26 100644
--- a/src/Wallabag/CoreBundle/Entity/TaggingRule.php
+++ b/src/Wallabag/CoreBundle/Entity/TaggingRule.php
@@ -31,7 +31,7 @@ class TaggingRule
31 * @Assert\Length(max=255) 31 * @Assert\Length(max=255)
32 * @RulerZAssert\ValidRule( 32 * @RulerZAssert\ValidRule(
33 * allowed_variables={"title", "url", "isArchived", "isStared", "content", "language", "mimetype", "readingTime", "domainName"}, 33 * allowed_variables={"title", "url", "isArchived", "isStared", "content", "language", "mimetype", "readingTime", "domainName"},
34 * allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or", "matches"} 34 * allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or", "matches", "notmatches"}
35 * ) 35 * )
36 * @ORM\Column(name="rule", type="string", nullable=false) 36 * @ORM\Column(name="rule", type="string", nullable=false)
37 */ 37 */
@@ -87,7 +87,7 @@ class TaggingRule
87 /** 87 /**
88 * Set tags. 88 * Set tags.
89 * 89 *
90 * @param array<string> $tags 90 * @param array <string> $tags
91 * 91 *
92 * @return TaggingRule 92 * @return TaggingRule
93 */ 93 */