Move all files to test-driven-drupal/demo/drupal-london/
This commit is contained in:
parent
0db961b741
commit
695d8b0299
44 changed files with 0 additions and 0 deletions
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\opdavies_talks\Controller;
|
||||
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
use Drupal\opdavies_talks\Repository\TalkNodeRepository;
|
||||
|
||||
final class TalksPageController {
|
||||
|
||||
use StringTranslationTrait;
|
||||
|
||||
public function __construct(private TalkNodeRepository $talkRepository) {
|
||||
}
|
||||
|
||||
public function __invoke(): array {
|
||||
$talkCount = $this->talkRepository->getCount();
|
||||
|
||||
return ['#markup' => $this->t('<span data-talk-count>:count talks</span>', [':count' => $talkCount])];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\opdavies_talks\Repository;
|
||||
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
|
||||
final class TalkNodeRepository {
|
||||
|
||||
public function __construct(private EntityTypeManagerInterface $entityTypeManager) {
|
||||
}
|
||||
|
||||
public function getCount(): int {
|
||||
$talks = $this->entityTypeManager->getStorage('node')->loadByProperties();
|
||||
|
||||
return count($talks);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue