2015-02-08 22:05:51 +00:00
|
|
|
<?php
|
|
|
|
|
2018-11-26 19:00:01 +00:00
|
|
|
namespace Wallabag\CoreBundle\DataFixtures;
|
2015-02-08 22:05:51 +00:00
|
|
|
|
2018-11-26 19:00:01 +00:00
|
|
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
|
|
|
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
2020-06-15 06:25:59 +00:00
|
|
|
use Doctrine\Persistence\ObjectManager;
|
2015-02-08 22:05:51 +00:00
|
|
|
use Wallabag\CoreBundle\Entity\Entry;
|
2023-08-05 16:25:03 +00:00
|
|
|
use Wallabag\CoreBundle\Entity\Tag;
|
2018-11-26 19:00:01 +00:00
|
|
|
use Wallabag\UserBundle\DataFixtures\UserFixtures;
|
2023-08-05 16:25:03 +00:00
|
|
|
use Wallabag\UserBundle\Entity\User;
|
2015-02-08 22:05:51 +00:00
|
|
|
|
2018-11-26 19:00:01 +00:00
|
|
|
class EntryFixtures extends Fixture implements DependentFixtureInterface
|
2015-02-08 22:05:51 +00:00
|
|
|
{
|
|
|
|
/**
|
2015-08-20 05:53:55 +00:00
|
|
|
* {@inheritdoc}
|
2015-02-08 22:05:51 +00:00
|
|
|
*/
|
2020-06-15 06:25:59 +00:00
|
|
|
public function load(ObjectManager $manager): void
|
2015-02-08 22:05:51 +00:00
|
|
|
{
|
2018-12-29 18:22:05 +00:00
|
|
|
$entries = [
|
|
|
|
'entry1' => [
|
|
|
|
'user' => 'admin-user',
|
|
|
|
'url' => 'http://0.0.0.0/entry1',
|
|
|
|
'reading_time' => 11,
|
|
|
|
'domain' => 'domain.io',
|
|
|
|
'mime' => 'text/html',
|
|
|
|
'title' => 'test title entry1',
|
|
|
|
'content' => 'This is my content /o/',
|
|
|
|
'language' => 'en',
|
|
|
|
'tags' => ['foo-tag', 'baz-tag'],
|
|
|
|
],
|
|
|
|
'entry2' => [
|
|
|
|
'user' => 'admin-user',
|
|
|
|
'url' => 'http://0.0.0.0/entry2',
|
|
|
|
'reading_time' => 1,
|
|
|
|
'domain' => 'domain.io',
|
|
|
|
'mime' => 'text/html',
|
|
|
|
'title' => 'test title entry2',
|
|
|
|
'content' => 'This is my content /o/',
|
|
|
|
'origin' => 'ftp://oneftp.tld',
|
|
|
|
'language' => 'fr',
|
|
|
|
],
|
|
|
|
'entry3' => [
|
|
|
|
'user' => 'bob-user',
|
|
|
|
'url' => 'http://0.0.0.0/entry3',
|
|
|
|
'reading_time' => 1,
|
|
|
|
'domain' => 'domain.io',
|
|
|
|
'mime' => 'text/html',
|
|
|
|
'title' => 'test title entry3',
|
|
|
|
'content' => 'This is my content /o/',
|
|
|
|
'language' => 'en',
|
|
|
|
'tags' => ['foo-tag', 'bar-tag', 'bob-tag'],
|
|
|
|
],
|
|
|
|
'entry4' => [
|
|
|
|
'user' => 'admin-user',
|
|
|
|
'url' => 'http://0.0.0.0/entry4',
|
|
|
|
'reading_time' => 12,
|
|
|
|
'domain' => 'domain.io',
|
|
|
|
'mime' => 'text/html',
|
|
|
|
'title' => 'test title entry4',
|
|
|
|
'content' => 'This is my content /o/',
|
|
|
|
'language' => 'en',
|
|
|
|
'tags' => ['foo-tag', 'bar-tag'],
|
|
|
|
],
|
|
|
|
'entry5' => [
|
|
|
|
'user' => 'admin-user',
|
|
|
|
'url' => 'http://0.0.0.0/entry5',
|
|
|
|
'reading_time' => 12,
|
|
|
|
'domain' => 'domain.io',
|
|
|
|
'mime' => 'text/html',
|
|
|
|
'title' => 'test title entry5',
|
|
|
|
'content' => 'This is my content /o/',
|
|
|
|
'language' => 'fr',
|
|
|
|
'starred' => true,
|
|
|
|
'preview' => 'http://0.0.0.0/image.jpg',
|
|
|
|
],
|
|
|
|
'entry6' => [
|
|
|
|
'user' => 'admin-user',
|
|
|
|
'url' => 'http://0.0.0.0/entry6',
|
|
|
|
'reading_time' => 12,
|
|
|
|
'domain' => 'domain.io',
|
|
|
|
'mime' => 'text/html',
|
|
|
|
'title' => 'test title entry6',
|
|
|
|
'content' => 'This is my content /o/',
|
|
|
|
'language' => 'de',
|
|
|
|
'archived' => true,
|
|
|
|
'tags' => ['bar-tag'],
|
2023-07-28 12:58:43 +00:00
|
|
|
'is_not_parsed' => true,
|
2018-12-29 18:22:05 +00:00
|
|
|
],
|
|
|
|
];
|
2015-03-28 20:43:49 +00:00
|
|
|
|
2018-12-29 18:22:05 +00:00
|
|
|
foreach ($entries as $reference => $item) {
|
2023-08-05 16:25:03 +00:00
|
|
|
$entry = new Entry($this->getReference($item['user'], User::class));
|
2018-12-29 18:22:05 +00:00
|
|
|
$entry->setUrl($item['url']);
|
|
|
|
$entry->setReadingTime($item['reading_time']);
|
|
|
|
$entry->setDomainName($item['domain']);
|
|
|
|
$entry->setMimetype($item['mime']);
|
|
|
|
$entry->setTitle($item['title']);
|
|
|
|
$entry->setContent($item['content']);
|
|
|
|
$entry->setLanguage($item['language']);
|
|
|
|
|
|
|
|
if (isset($item['tags'])) {
|
|
|
|
foreach ($item['tags'] as $tag) {
|
2023-08-05 16:25:03 +00:00
|
|
|
$entry->addTag($this->getReference($tag, Tag::class));
|
2018-12-29 18:22:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($item['origin'])) {
|
|
|
|
$entry->setOriginUrl($item['origin']);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($item['starred'])) {
|
|
|
|
$entry->setStarred($item['starred']);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($item['archived'])) {
|
|
|
|
$entry->setArchived($item['archived']);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($item['preview'])) {
|
|
|
|
$entry->setPreviewPicture($item['preview']);
|
|
|
|
}
|
|
|
|
|
2023-07-28 12:58:43 +00:00
|
|
|
if (isset($item['is_not_parsed'])) {
|
|
|
|
$entry->setNotParsed($item['is_not_parsed']);
|
|
|
|
}
|
|
|
|
|
2018-12-29 18:22:05 +00:00
|
|
|
$manager->persist($entry);
|
|
|
|
$this->addReference($reference, $entry);
|
|
|
|
}
|
2015-03-28 20:43:49 +00:00
|
|
|
|
2015-02-10 21:32:42 +00:00
|
|
|
$manager->flush();
|
2015-02-08 22:05:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-08-20 05:53:55 +00:00
|
|
|
* {@inheritdoc}
|
2015-02-08 22:05:51 +00:00
|
|
|
*/
|
2018-11-26 19:00:01 +00:00
|
|
|
public function getDependencies()
|
2015-02-08 22:05:51 +00:00
|
|
|
{
|
2018-11-26 19:00:01 +00:00
|
|
|
return [
|
|
|
|
UserFixtures::class,
|
|
|
|
TagFixtures::class,
|
|
|
|
];
|
2015-02-08 22:05:51 +00:00
|
|
|
}
|
|
|
|
}
|