mirror of
https://github.com/doctrine/doctrine-website.git
synced 2026-03-23 22:32:11 +01:00
Maintaining a standalone static website generator project that is not reused outside our website adds maintenance overhead. For instance, support for using `phpdocumentor/guides` was implemented in the website repo rather than the standalone generator package, which was still using the `doctrine/rst-parser` package that we want to abandon.
39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Doctrine\Website\DataSources;
|
|
|
|
use Doctrine\Website\StaticGenerator\SourceFile\SourceFileFilesystemReader;
|
|
|
|
final readonly class BlogPosts implements DataSource
|
|
{
|
|
public function __construct(
|
|
private SourceFileFilesystemReader $sourceFileFilesystemReader,
|
|
) {
|
|
}
|
|
|
|
/** @return mixed[][] */
|
|
public function getSourceRows(): array
|
|
{
|
|
$sourceFiles = $this->sourceFileFilesystemReader
|
|
->getSourceFiles()->in('/blog/');
|
|
|
|
$blogPosts = [];
|
|
|
|
foreach ($sourceFiles as $sourceFile) {
|
|
$blogPosts[] = [
|
|
'url' => $sourceFile->getParameter('url'),
|
|
'slug' => $sourceFile->getParameter('slug'),
|
|
'title' => $sourceFile->getParameter('title'),
|
|
'authorName' => (string) $sourceFile->getParameter('authorName'),
|
|
'authorEmail' => (string) $sourceFile->getParameter('authorEmail'),
|
|
'contents' => $sourceFile->getContents(),
|
|
'date' => $sourceFile->getDate(),
|
|
];
|
|
}
|
|
|
|
return $blogPosts;
|
|
}
|
|
}
|