2015-02-08 23:05:51 +01:00
|
|
|
<?php
|
|
|
|
|
2018-11-26 20:00:01 +01:00
|
|
|
namespace Wallabag\CoreBundle\DataFixtures;
|
2015-02-08 23:05:51 +01:00
|
|
|
|
2018-11-26 20:00:01 +01:00
|
|
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
|
|
|
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
2020-06-15 08:25:59 +02:00
|
|
|
use Doctrine\Persistence\ObjectManager;
|
2015-02-08 23:05:51 +01:00
|
|
|
use Wallabag\CoreBundle\Entity\Entry;
|
2018-11-26 20:00:01 +01:00
|
|
|
use Wallabag\UserBundle\DataFixtures\UserFixtures;
|
2015-02-08 23:05:51 +01:00
|
|
|
|
2018-11-26 20:00:01 +01:00
|
|
|
class EntryFixtures extends Fixture implements DependentFixtureInterface
|
2015-02-08 23:05:51 +01:00
|
|
|
{
|
|
|
|
/**
|
2015-08-20 07:53:55 +02:00
|
|
|
* {@inheritdoc}
|
2015-02-08 23:05:51 +01:00
|
|
|
*/
|
2020-06-15 08:25:59 +02:00
|
|
|
public function load(ObjectManager $manager): void
|
2015-02-08 23:05:51 +01:00
|
|
|
{
|
2018-12-29 19:22:05 +01: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'],
|
|
|
|
],
|
|
|
|
];
|
2015-03-28 21:43:49 +01:00
|
|
|
|
2018-12-29 19:22:05 +01:00
|
|
|
foreach ($entries as $reference => $item) {
|
|
|
|
$entry = new Entry($this->getReference($item['user']));
|
|
|
|
$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) {
|
|
|
|
$entry->addTag($this->getReference($tag));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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']);
|
|
|
|
}
|
|
|
|
|
|
|
|
$manager->persist($entry);
|
|
|
|
$this->addReference($reference, $entry);
|
|
|
|
}
|
2015-03-28 21:43:49 +01:00
|
|
|
|
2015-02-10 22:32:42 +01:00
|
|
|
$manager->flush();
|
2015-02-08 23:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-08-20 07:53:55 +02:00
|
|
|
* {@inheritdoc}
|
2015-02-08 23:05:51 +01:00
|
|
|
*/
|
2018-11-26 20:00:01 +01:00
|
|
|
public function getDependencies()
|
2015-02-08 23:05:51 +01:00
|
|
|
{
|
2018-11-26 20:00:01 +01:00
|
|
|
return [
|
|
|
|
UserFixtures::class,
|
|
|
|
TagFixtures::class,
|
|
|
|
];
|
2015-02-08 23:05:51 +01:00
|
|
|
}
|
|
|
|
}
|