forked from biblioverse/biblioteca
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Kobo): Sync bookmark and progression
- Loading branch information
Showing
7 changed files
with
337 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20240812195147 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Add bookmarks'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->addSql('CREATE TABLE bookmark_user (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, book_id INT NOT NULL, percent DOUBLE PRECISION DEFAULT NULL, source_percent DOUBLE PRECISION DEFAULT NULL, location_value VARCHAR(255) DEFAULT NULL, location_type VARCHAR(255) DEFAULT NULL, location_source VARCHAR(255) DEFAULT NULL, updated DATETIME DEFAULT NULL, INDEX IDX_6F0BEE95A76ED395 (user_id), INDEX IDX_6F0BEE9516A2B381 (book_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB'); | ||
$this->addSql('ALTER TABLE bookmark_user ADD CONSTRAINT FK_6F0BEE95A76ED395 FOREIGN KEY (user_id) REFERENCES `user` (id)'); | ||
$this->addSql('ALTER TABLE bookmark_user ADD CONSTRAINT FK_6F0BEE9516A2B381 FOREIGN KEY (book_id) REFERENCES book (id)'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE bookmark_user DROP FOREIGN KEY FK_6F0BEE95A76ED395'); | ||
$this->addSql('ALTER TABLE bookmark_user DROP FOREIGN KEY FK_6F0BEE9516A2B381'); | ||
$this->addSql('DROP TABLE bookmark_user'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
<?php | ||
|
||
namespace App\Entity; | ||
|
||
use App\Repository\BookmarkUserRepository; | ||
use Doctrine\DBAL\Types\Types; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Gedmo\Mapping\Annotation as Gedmo; | ||
|
||
#[ORM\Entity(repositoryClass: BookmarkUserRepository::class)] | ||
class BookmarkUser | ||
{ | ||
#[ORM\Id] | ||
#[ORM\GeneratedValue] | ||
#[ORM\Column] | ||
private ?int $id = null; | ||
|
||
#[ORM\Column(nullable: true)] | ||
private ?float $percent = null; | ||
|
||
#[ORM\Column(nullable: true)] | ||
private ?float $sourcePercent = null; | ||
|
||
#[ORM\Column(length: 255, nullable: true)] | ||
private ?string $locationValue = null; | ||
|
||
#[ORM\Column(length: 255, nullable: true)] | ||
private ?string $locationType = null; | ||
|
||
#[ORM\Column(length: 255, nullable: true)] | ||
private ?string $locationSource = null; | ||
|
||
#[ORM\ManyToOne(inversedBy: 'bookmarkUsers')] | ||
#[ORM\JoinColumn(nullable: false)] | ||
private ?User $user; | ||
|
||
#[ORM\ManyToOne(inversedBy: 'bookmarkUsers')] | ||
#[ORM\JoinColumn(nullable: false)] | ||
private ?Book $book; | ||
|
||
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] | ||
#[Gedmo\Timestampable(on: 'update')] | ||
private ?\DateTimeInterface $updated; | ||
|
||
public function __construct(?Book $book, ?User $user) | ||
{ | ||
$this->book = $book; | ||
$this->user = $user; | ||
} | ||
|
||
public function getId(): ?int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getPercent(): ?float | ||
{ | ||
return $this->percent; | ||
} | ||
|
||
public function setPercent(?float $percent): static | ||
{ | ||
$this->percent = $percent; | ||
|
||
return $this; | ||
} | ||
|
||
public function getSourcePercent(): ?float | ||
{ | ||
return $this->sourcePercent; | ||
} | ||
|
||
public function setSourcePercent(?float $sourcePercent): static | ||
{ | ||
$this->sourcePercent = $sourcePercent; | ||
|
||
return $this; | ||
} | ||
|
||
public function getLocationValue(): ?string | ||
{ | ||
return $this->locationValue; | ||
} | ||
|
||
public function setLocationValue(?string $locationValue): static | ||
{ | ||
$this->locationValue = $locationValue; | ||
|
||
return $this; | ||
} | ||
|
||
public function getLocationType(): ?string | ||
{ | ||
return $this->locationType; | ||
} | ||
|
||
public function setLocationType(?string $locationType): static | ||
{ | ||
$this->locationType = $locationType; | ||
|
||
return $this; | ||
} | ||
|
||
public function getLocationSource(): ?string | ||
{ | ||
return $this->locationSource; | ||
} | ||
|
||
public function setLocationSource(?string $locationSource): static | ||
{ | ||
$this->locationSource = $locationSource; | ||
|
||
return $this; | ||
} | ||
|
||
public function getUser(): ?User | ||
{ | ||
return $this->user; | ||
} | ||
|
||
public function setUser(?User $user): static | ||
{ | ||
$this->user = $user; | ||
|
||
return $this; | ||
} | ||
|
||
public function hasLocation(): bool | ||
{ | ||
return $this->locationValue !== null; | ||
} | ||
|
||
public function setBook(?Book $book): self | ||
{ | ||
$this->book = $book; | ||
|
||
return $this; | ||
} | ||
|
||
public function getBook(): ?Book | ||
{ | ||
return $this->book; | ||
} | ||
|
||
public function getUpdated(): ?\DateTimeInterface | ||
{ | ||
return $this->updated; | ||
} | ||
|
||
public function setUpdated(?\DateTimeInterface $updated): void | ||
{ | ||
$this->updated = $updated; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.