2020-08-21 12:00:00 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-08-24 09:26:44 +01:00
|
|
|
namespace Drupal\opdavies_talks\Repository;
|
2020-08-21 12:00:00 +01:00
|
|
|
|
|
|
|
use Drupal\Core\Entity\EntityStorageInterface;
|
|
|
|
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
2020-09-04 20:49:23 +01:00
|
|
|
use Drupal\opdavies_talks\Entity\Node\Talk;
|
2020-12-17 23:25:59 +00:00
|
|
|
use Tightenco\Collect\Support\Collection;
|
2020-08-21 12:00:00 +01:00
|
|
|
|
|
|
|
final class TalkRepository {
|
|
|
|
|
|
|
|
private EntityStorageInterface $nodeStorage;
|
|
|
|
|
|
|
|
public function __construct(EntityTypeManagerInterface $entityTypeManager) {
|
|
|
|
$this->nodeStorage = $entityTypeManager->getStorage('node');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Collection|Talk[]
|
|
|
|
*/
|
|
|
|
public function getAll(bool $publishedOnly = FALSE): Collection {
|
|
|
|
$properties = ['type' => 'talk'];
|
|
|
|
|
|
|
|
if ($publishedOnly) {
|
|
|
|
$properties['status'] = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Collection(
|
|
|
|
$this->nodeStorage->loadByProperties($properties)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|