2016-02-07 16:52:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
2024-02-19 01:30:12 +01:00
|
|
|
namespace Wallabag\Entity;
|
2016-02-07 16:52:59 +01:00
|
|
|
|
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
|
use JMS\Serializer\Annotation\Exclude;
|
2017-07-01 09:52:38 +02:00
|
|
|
use JMS\Serializer\Annotation\ExclusionPolicy;
|
2016-10-02 16:06:42 +02:00
|
|
|
use JMS\Serializer\Annotation\Groups;
|
2017-07-01 09:52:38 +02:00
|
|
|
use JMS\Serializer\Annotation\SerializedName;
|
|
|
|
|
use JMS\Serializer\Annotation\VirtualProperty;
|
2017-05-07 17:21:30 +02:00
|
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
2024-02-19 01:30:12 +01:00
|
|
|
use Wallabag\Helper\EntityTimestampsTrait;
|
2025-04-05 12:55:51 +02:00
|
|
|
use Wallabag\Repository\AnnotationRepository;
|
2016-02-07 16:52:59 +01:00
|
|
|
|
|
|
|
|
/**
|
2016-02-26 13:59:08 +01:00
|
|
|
* Annotation.
|
2016-02-07 16:52:59 +01:00
|
|
|
*/
|
2025-04-05 12:55:51 +02:00
|
|
|
#[ORM\Table(name: 'annotation')]
|
|
|
|
|
#[ORM\Entity(repositoryClass: AnnotationRepository::class)]
|
|
|
|
|
#[ORM\HasLifecycleCallbacks]
|
2025-04-05 15:12:30 +02:00
|
|
|
#[ExclusionPolicy('none')]
|
2016-02-26 13:59:08 +01:00
|
|
|
class Annotation
|
2016-02-07 16:52:59 +01:00
|
|
|
{
|
2017-07-06 09:00:37 +02:00
|
|
|
use EntityTimestampsTrait;
|
|
|
|
|
|
2016-02-07 16:52:59 +01:00
|
|
|
/**
|
|
|
|
|
* @var int
|
|
|
|
|
*/
|
2025-04-05 12:55:51 +02:00
|
|
|
#[ORM\Column(name: 'id', type: 'integer')]
|
|
|
|
|
#[ORM\Id]
|
|
|
|
|
#[ORM\GeneratedValue(strategy: 'AUTO')]
|
2016-02-07 16:52:59 +01:00
|
|
|
private $id;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2025-04-05 12:55:51 +02:00
|
|
|
#[ORM\Column(name: 'text', type: 'text')]
|
2025-04-05 15:12:30 +02:00
|
|
|
#[Groups(['entries_for_user', 'export_all'])]
|
2016-02-07 16:52:59 +01:00
|
|
|
private $text;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var \DateTime
|
|
|
|
|
*/
|
2025-04-05 12:55:51 +02:00
|
|
|
#[ORM\Column(name: 'created_at', type: 'datetime')]
|
2016-02-07 16:52:59 +01:00
|
|
|
private $createdAt;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var \DateTime
|
|
|
|
|
*/
|
2025-04-05 12:55:51 +02:00
|
|
|
#[ORM\Column(name: 'updated_at', type: 'datetime')]
|
2016-02-07 16:52:59 +01:00
|
|
|
private $updatedAt;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2025-04-05 12:55:51 +02:00
|
|
|
#[ORM\Column(name: 'quote', type: 'text')]
|
2025-04-05 15:06:57 +02:00
|
|
|
#[Assert\Length(max: 10000, maxMessage: 'validator.quote_length_too_high')]
|
2025-04-05 15:12:30 +02:00
|
|
|
#[Groups(['entries_for_user', 'export_all'])]
|
2016-02-07 16:52:59 +01:00
|
|
|
private $quote;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
2025-04-05 12:55:51 +02:00
|
|
|
#[ORM\Column(name: 'ranges', type: 'array')]
|
2025-04-05 15:12:30 +02:00
|
|
|
#[Groups(['entries_for_user', 'export_all'])]
|
2016-02-07 16:52:59 +01:00
|
|
|
private $ranges;
|
|
|
|
|
|
2025-04-05 12:55:51 +02:00
|
|
|
#[ORM\ManyToOne(targetEntity: User::class)]
|
2025-04-05 15:12:30 +02:00
|
|
|
#[Exclude]
|
2016-02-07 16:52:59 +01:00
|
|
|
private $user;
|
|
|
|
|
|
2025-04-05 12:55:51 +02:00
|
|
|
#[ORM\JoinColumn(name: 'entry_id', referencedColumnName: 'id', onDelete: 'cascade')]
|
|
|
|
|
#[ORM\ManyToOne(targetEntity: Entry::class, inversedBy: 'annotations')]
|
2025-04-05 15:12:30 +02:00
|
|
|
#[Exclude]
|
2016-02-07 16:52:59 +01:00
|
|
|
private $entry;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @param User $user
|
|
|
|
|
*/
|
2016-03-27 19:20:43 +02:00
|
|
|
public function __construct(User $user)
|
2016-02-07 16:52:59 +01:00
|
|
|
{
|
|
|
|
|
$this->user = $user;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get id.
|
|
|
|
|
*
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
public function getId()
|
|
|
|
|
{
|
|
|
|
|
return $this->id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set text.
|
|
|
|
|
*
|
|
|
|
|
* @param string $text
|
|
|
|
|
*
|
2016-02-26 13:59:08 +01:00
|
|
|
* @return Annotation
|
2016-02-07 16:52:59 +01:00
|
|
|
*/
|
|
|
|
|
public function setText($text)
|
|
|
|
|
{
|
|
|
|
|
$this->text = $text;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get text.
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getText()
|
|
|
|
|
{
|
|
|
|
|
return $this->text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get created.
|
|
|
|
|
*
|
|
|
|
|
* @return \DateTime
|
|
|
|
|
*/
|
|
|
|
|
public function getCreatedAt()
|
|
|
|
|
{
|
|
|
|
|
return $this->createdAt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get updated.
|
|
|
|
|
*
|
|
|
|
|
* @return \DateTime
|
|
|
|
|
*/
|
|
|
|
|
public function getUpdatedAt()
|
|
|
|
|
{
|
|
|
|
|
return $this->updatedAt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get quote.
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getQuote()
|
|
|
|
|
{
|
|
|
|
|
return $this->quote;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set quote.
|
|
|
|
|
*
|
|
|
|
|
* @param string $quote
|
|
|
|
|
*
|
2016-02-26 13:59:08 +01:00
|
|
|
* @return Annotation
|
2016-02-07 16:52:59 +01:00
|
|
|
*/
|
|
|
|
|
public function setQuote($quote)
|
|
|
|
|
{
|
|
|
|
|
$this->quote = $quote;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get ranges.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function getRanges()
|
|
|
|
|
{
|
|
|
|
|
return $this->ranges;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set ranges.
|
|
|
|
|
*
|
|
|
|
|
* @param array $ranges
|
|
|
|
|
*
|
2016-02-26 13:59:08 +01:00
|
|
|
* @return Annotation
|
2016-02-07 16:52:59 +01:00
|
|
|
*/
|
|
|
|
|
public function setRanges($ranges)
|
|
|
|
|
{
|
|
|
|
|
$this->ranges = $ranges;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set user.
|
|
|
|
|
*
|
2016-03-27 19:20:43 +02:00
|
|
|
* @param User $user
|
2016-02-07 16:52:59 +01:00
|
|
|
*
|
2016-02-26 13:59:08 +01:00
|
|
|
* @return Annotation
|
2016-02-07 16:52:59 +01:00
|
|
|
*/
|
|
|
|
|
public function setUser($user)
|
|
|
|
|
{
|
|
|
|
|
$this->user = $user;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get user.
|
|
|
|
|
*
|
2016-03-27 19:20:43 +02:00
|
|
|
* @return User
|
2016-02-07 16:52:59 +01:00
|
|
|
*/
|
|
|
|
|
public function getUser()
|
|
|
|
|
{
|
|
|
|
|
return $this->user;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-05 15:12:30 +02:00
|
|
|
#[VirtualProperty]
|
|
|
|
|
#[SerializedName('user')]
|
2016-02-07 16:52:59 +01:00
|
|
|
public function getUserName()
|
|
|
|
|
{
|
|
|
|
|
return $this->user->getName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set entry.
|
|
|
|
|
*
|
|
|
|
|
* @param Entry $entry
|
|
|
|
|
*
|
2016-02-26 13:59:08 +01:00
|
|
|
* @return Annotation
|
2016-02-07 16:52:59 +01:00
|
|
|
*/
|
|
|
|
|
public function setEntry($entry)
|
|
|
|
|
{
|
|
|
|
|
$this->entry = $entry;
|
2016-02-26 13:59:08 +01:00
|
|
|
$entry->setAnnotation($this);
|
2016-02-07 16:52:59 +01:00
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get entry.
|
|
|
|
|
*
|
|
|
|
|
* @return Entry
|
|
|
|
|
*/
|
|
|
|
|
public function getEntry()
|
|
|
|
|
{
|
|
|
|
|
return $this->entry;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-05 15:12:30 +02:00
|
|
|
#[VirtualProperty]
|
|
|
|
|
#[SerializedName('annotator_schema_version')]
|
2016-02-07 16:52:59 +01:00
|
|
|
public function getVersion()
|
|
|
|
|
{
|
|
|
|
|
return 'v1.0';
|
|
|
|
|
}
|
|
|
|
|
}
|