docs: DrupalCon updates
This commit is contained in:
parent
6cf7d0fee4
commit
675e89e9d1
28 changed files with 1240 additions and 144 deletions
37
test-driven-drupal/code/17.txt
Normal file
37
test-driven-drupal/code/17.txt
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?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
|
Loading…
Add table
Add a link
Reference in a new issue