diff options
-rw-r--r-- | app/DoctrineMigrations/Version20171105202000.php | 55 | ||||
-rw-r--r-- | src/Wallabag/ApiBundle/Controller/EntryRestController.php | 11 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Entry.php | 33 |
3 files changed, 99 insertions, 0 deletions
diff --git a/app/DoctrineMigrations/Version20171105202000.php b/app/DoctrineMigrations/Version20171105202000.php new file mode 100644 index 00000000..b1cff9ce --- /dev/null +++ b/app/DoctrineMigrations/Version20171105202000.php | |||
@@ -0,0 +1,55 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | /** | ||
11 | * Add origin_url column | ||
12 | */ | ||
13 | class Version20171105202000 extends AbstractMigration implements ContainerAwareInterface | ||
14 | { | ||
15 | /** | ||
16 | * @var ContainerInterface | ||
17 | */ | ||
18 | private $container; | ||
19 | |||
20 | public function setContainer(ContainerInterface $container = null) | ||
21 | { | ||
22 | $this->container = $container; | ||
23 | } | ||
24 | |||
25 | /** | ||
26 | * @param Schema $schema | ||
27 | */ | ||
28 | public function up(Schema $schema) | ||
29 | { | ||
30 | $entryTable = $schema->getTable($this->getTable('entry')); | ||
31 | |||
32 | $this->skipIf($entryTable->hasColumn('origin_url'), 'It seems that you already played this migration.'); | ||
33 | |||
34 | $entryTable->addColumn('origin_url', 'text', [ | ||
35 | 'notnull' => false, | ||
36 | ]); | ||
37 | } | ||
38 | |||
39 | /** | ||
40 | * @param Schema $schema | ||
41 | */ | ||
42 | public function down(Schema $schema) | ||
43 | { | ||
44 | $entryTable = $schema->getTable($this->getTable('entry')); | ||
45 | |||
46 | $this->skipIf(!$entryTable->hasColumn('origin_url'), 'It seems that you already played this migration.'); | ||
47 | |||
48 | $entryTable->dropColumn('origin_url'); | ||
49 | } | ||
50 | |||
51 | private function getTable($tableName) | ||
52 | { | ||
53 | return $this->container->getParameter('database_table_prefix') . $tableName; | ||
54 | } | ||
55 | } | ||
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php index 6f161a08..5a9afc69 100644 --- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php +++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php | |||
@@ -309,6 +309,7 @@ class EntryRestController extends WallabagRestController | |||
309 | * {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"}, | 309 | * {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"}, |
310 | * {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"}, | 310 | * {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"}, |
311 | * {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="will generate a public link for the entry"}, | 311 | * {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="will generate a public link for the entry"}, |
312 | * {"name"="origin_url", "dataType"="string", "required"=false, "format"="http://www.test.com/article.html", "description"="Origin url for the entry."}, | ||
312 | * } | 313 | * } |
313 | * ) | 314 | * ) |
314 | * | 315 | * |
@@ -368,6 +369,10 @@ class EntryRestController extends WallabagRestController | |||
368 | $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $data['tags']); | 369 | $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $data['tags']); |
369 | } | 370 | } |
370 | 371 | ||
372 | if (!empty($data['origin_url'])) { | ||
373 | $entry->setOriginUrl($data['origin_url']); | ||
374 | } | ||
375 | |||
371 | if (null !== $data['isPublic']) { | 376 | if (null !== $data['isPublic']) { |
372 | if (true === (bool) $data['isPublic'] && null === $entry->getUid()) { | 377 | if (true === (bool) $data['isPublic'] && null === $entry->getUid()) { |
373 | $entry->generateUid(); | 378 | $entry->generateUid(); |
@@ -404,6 +409,7 @@ class EntryRestController extends WallabagRestController | |||
404 | * {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"}, | 409 | * {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"}, |
405 | * {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"}, | 410 | * {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"}, |
406 | * {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="will generate a public link for the entry"}, | 411 | * {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="will generate a public link for the entry"}, |
412 | * {"name"="origin_url", "dataType"="string", "required"=false, "format"="http://www.test.com/article.html", "description"="Origin url for the entry."}, | ||
407 | * } | 413 | * } |
408 | * ) | 414 | * ) |
409 | * | 415 | * |
@@ -480,6 +486,10 @@ class EntryRestController extends WallabagRestController | |||
480 | } | 486 | } |
481 | } | 487 | } |
482 | 488 | ||
489 | if (!empty($data['origin_url'])) { | ||
490 | $entry->setOriginUrl($data['origin_url']); | ||
491 | } | ||
492 | |||
483 | $em = $this->getDoctrine()->getManager(); | 493 | $em = $this->getDoctrine()->getManager(); |
484 | $em->persist($entry); | 494 | $em->persist($entry); |
485 | $em->flush(); | 495 | $em->flush(); |
@@ -778,6 +788,7 @@ class EntryRestController extends WallabagRestController | |||
778 | 'picture' => $request->request->get('preview_picture'), | 788 | 'picture' => $request->request->get('preview_picture'), |
779 | 'publishedAt' => $request->request->get('published_at'), | 789 | 'publishedAt' => $request->request->get('published_at'), |
780 | 'authors' => $request->request->get('authors', ''), | 790 | 'authors' => $request->request->get('authors', ''), |
791 | 'origin_url' => $request->request->get('origin_url', ''), | ||
781 | ]; | 792 | ]; |
782 | } | 793 | } |
783 | 794 | ||
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index cfb8db75..445cc45e 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php | |||
@@ -245,6 +245,15 @@ class Entry | |||
245 | */ | 245 | */ |
246 | private $tags; | 246 | private $tags; |
247 | 247 | ||
248 | /** | ||
249 | * @var string | ||
250 | * | ||
251 | * @ORM\Column(name="origin_url", type="text", nullable=true) | ||
252 | * | ||
253 | * @Groups({"entries_for_user", "export_all"}) | ||
254 | */ | ||
255 | private $originUrl; | ||
256 | |||
248 | /* | 257 | /* |
249 | * @param User $user | 258 | * @param User $user |
250 | */ | 259 | */ |
@@ -831,4 +840,28 @@ class Entry | |||
831 | 840 | ||
832 | return $this; | 841 | return $this; |
833 | } | 842 | } |
843 | |||
844 | /** | ||
845 | * Set origin url. | ||
846 | * | ||
847 | * @param string $originUrl | ||
848 | * | ||
849 | * @return Entry | ||
850 | */ | ||
851 | public function setOriginUrl($originUrl) | ||
852 | { | ||
853 | $this->originUrl = $originUrl; | ||
854 | |||
855 | return $this; | ||
856 | } | ||
857 | |||
858 | /** | ||
859 | * Get origin url. | ||
860 | * | ||
861 | * @return string | ||
862 | */ | ||
863 | public function getOriginUrl() | ||
864 | { | ||
865 | return $this->originUrl; | ||
866 | } | ||
834 | } | 867 | } |