Set talk type for existing talks
This commit is contained in:
parent
239b2c071c
commit
c44990643e
4 changed files with 56 additions and 1 deletions
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\opd_talks\Repository;
|
||||
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\custom\Entity\Node\Talk;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
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)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue