Extract a method for providing default properties and values
This commit is contained in:
parent
abe0f3d93b
commit
1f0926ac16
|
@ -22,9 +22,7 @@ final class TalkRepository {
|
||||||
* @return Collection|Talk[]
|
* @return Collection|Talk[]
|
||||||
*/
|
*/
|
||||||
public function findAll(): Collection {
|
public function findAll(): Collection {
|
||||||
$talks = $this->nodeStorage->loadByProperties([
|
$talks = $this->nodeStorage->loadByProperties($this->defaultProperties());
|
||||||
'type' => 'talk',
|
|
||||||
]);
|
|
||||||
|
|
||||||
return new Collection($talks);
|
return new Collection($talks);
|
||||||
}
|
}
|
||||||
|
@ -33,12 +31,20 @@ final class TalkRepository {
|
||||||
* @return Collection|Talk[]
|
* @return Collection|Talk[]
|
||||||
*/
|
*/
|
||||||
public function findAllPublished(): Collection {
|
public function findAllPublished(): Collection {
|
||||||
$talks = $this->nodeStorage->loadByProperties([
|
$talks = $this->nodeStorage->loadByProperties(array_merge(
|
||||||
'status' => NodeInterface::PUBLISHED,
|
$this->defaultProperties(),
|
||||||
'type' => 'talk',
|
[
|
||||||
]);
|
'status' => NodeInterface::PUBLISHED,
|
||||||
|
],
|
||||||
|
));
|
||||||
|
|
||||||
return new Collection($talks);
|
return new Collection($talks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function defaultProperties(): array {
|
||||||
|
return [
|
||||||
|
'type' => 'talk',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue