38 lines
802 B
Plaintext
38 lines
802 B
Plaintext
|
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
namespace Drupal\drupalcon\Repository;
|
||
|
|
||
|
use Drupal\Core\Entity\EntityStorageInterface;
|
||
|
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||
|
use Drupal\node\NodeInterface;
|
||
|
|
||
|
final class ArticleRepository {
|
||
|
|
||
|
private EntityStorageInterface $nodeStorage;
|
||
|
|
||
|
public function __construct(
|
||
|
private EntityTypeManagerInterface $entityTypeManager,
|
||
|
) {
|
||
|
$this->nodeStorage = $this->entityTypeManager->getStorage('node');
|
||
|
}
|
||
|
|
||
|
// start code
|
||
|
public function getAll(): array {
|
||
|
return $this->nodeStorage->loadByProperties([
|
||
|
'status' => NodeInterface::PUBLISHED,
|
||
|
]);
|
||
|
}
|
||
|
// end code
|
||
|
|
||
|
}
|
||
|
|
||
|
// start output
|
||
|
.. 2 / 2 (100%)
|
||
|
|
||
|
Time: 00:00.891, Memory: 6.00 MB
|
||
|
|
||
|
OK (2 tests, 22 assertions)
|
||
|
// end output
|