Skip to content

Commit 4c49ccb

Browse files
committed
new post twigs, fix post url path
1 parent ef13aa5 commit 4c49ccb

290 files changed

Lines changed: 260 additions & 28728 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/App/src/ConfigProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Light\App\Handler\GetIndexViewHandler;
1616
use Light\App\Resolver\EntityListenerResolver;
1717
use Mezzio\Application;
18-
use Ramsey\Uuid\Doctrine\UuidType;
18+
use Light\App\DBAL\Types\UuidType;
1919
use Roave\PsrContainerDoctrine\EntityManagerFactory;
2020
use Symfony\Component\Cache\Adapter\AdapterInterface;
2121

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
use Doctrine\Persistence\ObjectManager;
99
use Light\Blog\Entity\Author;
1010

11-
class AuthorsLoader extends Fixture
11+
class AuthorLoader extends Fixture
1212
{
1313
public function load(ObjectManager $manager): void
1414
{
15-
$jsonFile = __DIR__ . '/articles_by_category.json';
15+
$jsonFile = __DIR__ . '/articles_cleaned.json';
1616
$categories = json_decode(file_get_contents($jsonFile), true);
1717

1818
$seenAuthorIds = [];
@@ -22,7 +22,7 @@ public function load(ObjectManager $manager): void
2222
$authorData = $article['author'] ?? null;
2323
if (!$authorData) continue;
2424

25-
$wpAuthorId = $authorData['id'];
25+
$wpAuthorId = $authorData['user_email'];
2626
if (isset($seenAuthorIds[$wpAuthorId])) continue;
2727
$seenAuthorIds[$wpAuthorId] = true;
2828

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@
88
use Doctrine\Persistence\ObjectManager;
99
use Light\Blog\Entity\Category;
1010

11-
class CategoriesLoader extends Fixture
11+
class CategoryLoader extends Fixture
1212
{
1313
public function load(ObjectManager $manager): void
1414
{
15-
$jsonFile = __DIR__ . '/articles_by_category.json';
15+
$jsonFile = __DIR__ . '/articles_cleaned.json';
1616
$categories = json_decode(file_get_contents($jsonFile), true);
1717

1818
foreach ($categories as $cat) {
1919
$category = new Category();
2020
$category->setName($cat['name']);
2121
$category->setSlug($cat['slug']);
22+
$category->setVisibility($cat['isVisible'] ?? true);
2223

2324
$manager->persist($category);
24-
$this->addReference('category_' . $cat['id'], $category);
25+
$this->addReference('category_' . $cat['slug'], $category);
2526
}
2627

2728
$manager->flush();
Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@
88
use Doctrine\Bundle\FixturesBundle\Fixture;
99
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
1010
use Doctrine\Persistence\ObjectManager;
11-
use Light\Blog\Entity\Article;
11+
use Light\Blog\Entity\Post;
1212
use Light\Blog\Entity\Author;
1313
use Light\Blog\Entity\Category;
14-
use Light\Blog\Enum\ArticleStatusEnum;
14+
use Light\Blog\Enum\PostStatusEnum;
1515

16-
class ArticlesLoader extends Fixture implements DependentFixtureInterface
16+
class PostLoader extends Fixture implements DependentFixtureInterface
1717
{
1818
public function load(ObjectManager $manager): void
1919
{
20-
$jsonFile = __DIR__ . '/articles_by_category.json';
20+
$jsonFile = __DIR__ . '/articles_cleaned.json';
2121
$categories = json_decode(file_get_contents($jsonFile), true);
2222

2323
$usedSlugs = [];
2424

2525
foreach ($categories as $cat) {
2626
/** @var Category $category */
27-
$category = $this->getReference('category_' . $cat['id'], Category::class);
27+
$category = $this->getReference('category_' . $cat['slug'], Category::class);
2828

2929
foreach ($cat['articles'] as $articleData) {
30-
$wpAuthorId = $articleData['post_author'] ?? null;
30+
$wpAuthorId = $articleData['author']['user_email'] ?? null;
3131
if (!$wpAuthorId || !$this->hasReference('author_' . $wpAuthorId, Author::class)) {
3232
echo "SKIP (no author): {$articleData['post_title']}\n";
3333
continue;
@@ -46,36 +46,36 @@ public function load(ObjectManager $manager): void
4646
}
4747

4848
$status = match ($articleData['post_status']) {
49-
'publish' => ArticleStatusEnum::Published,
50-
'private' => ArticleStatusEnum::Private,
51-
default => ArticleStatusEnum::Draft,
49+
'publish' => PostStatusEnum::Published,
50+
'private' => PostStatusEnum::Private,
51+
default => PostStatusEnum::Draft,
5252
};
5353

5454
$rawDate = $articleData['post_date'] ?? '';
5555
$postDate = (!empty($rawDate) && $rawDate !== '0000-00-00 00:00:00')
5656
? new DateTimeImmutable($rawDate)
5757
: new DateTimeImmutable();
5858

59-
$article = new Article();
59+
$article = new Post();
6060
$article->setTitle($title);
6161
$article->setSlug($slug);
6262
$article->setPostDate($postDate);
6363
$article->setStatus($status);
6464
$article->setCategory($category);
6565
$article->setAuthor($author);
66+
$article->setExcerpt($articleData['excerpt'] ?? '');
6667

6768
$manager->persist($article);
6869
}
6970
}
7071

7172
$manager->flush();
7273
}
73-
7474
public function getDependencies(): array
7575
{
7676
return [
77-
AuthorsLoader::class,
78-
CategoriesLoader::class,
77+
AuthorLoader::class,
78+
CategoryLoader::class,
7979
];
8080
}
8181

@@ -85,4 +85,9 @@ private function slugify(string $text): string
8585
$text = preg_replace('/[^a-z0-9]+/', '-', $text);
8686
return trim($text, '-');
8787
}
88+
89+
public function getOrder(): int
90+
{
91+
return 3;
92+
}
8893
}

0 commit comments

Comments
 (0)