27 lines
607 B
PHP
27 lines
607 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Drupal\opdavies_blog\Repository;
|
|
|
|
use Drupal\Core\Entity\EntityStorageInterface;
|
|
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
|
use Tightenco\Collect\Support\Collection;
|
|
|
|
final class PostRepository {
|
|
|
|
private EntityStorageInterface $nodeStorage;
|
|
|
|
public function __construct(EntityTypeManagerInterface $entityTypeManager) {
|
|
$this->nodeStorage = $entityTypeManager->getStorage('node');
|
|
}
|
|
|
|
public function getAll(): Collection {
|
|
return new Collection(
|
|
$this->nodeStorage->loadByProperties([
|
|
'type' => 'post',
|
|
])
|
|
);
|
|
}
|
|
|
|
}
|