backports murph-skeleton
This commit is contained in:
parent
146533af30
commit
8dcc696595
|
@ -17,29 +17,13 @@ class CommentRepositoryQuery extends RepositoryQuery
|
|||
parent::__construct($repository, 'c', $paginator);
|
||||
}
|
||||
|
||||
public function useFilters(array $filters)
|
||||
protected function filterHandler(string $name, $value)
|
||||
{
|
||||
foreach ($filters as $name => $value) {
|
||||
if (null === $value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_int($value) || is_bool($value)) {
|
||||
$this->andWhere('.'.$name.' = :'.$name);
|
||||
$this->setParameter(':'.$name, $value);
|
||||
} elseif (is_string($value)) {
|
||||
$this->andWhere('.'.$name.' LIKE :'.$name);
|
||||
$this->setParameter(':'.$name, '%'.$value.'%');
|
||||
} else {
|
||||
if ('post' === $name) {
|
||||
$this
|
||||
->andWhere('.post = :postId')
|
||||
->setParameter(':postId', $value->getId())
|
||||
;
|
||||
}
|
||||
}
|
||||
if ('post' === $name) {
|
||||
$this
|
||||
->andWhere('.post = :postId')
|
||||
->setParameter(':postId', $value->getId())
|
||||
;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,27 +40,11 @@ class PostRepositoryQuery extends RepositoryQuery
|
|||
;
|
||||
}
|
||||
|
||||
public function useFilters(array $filters)
|
||||
protected function filterHandler(string $name, $value)
|
||||
{
|
||||
foreach ($filters as $name => $value) {
|
||||
if (null === $value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_int($value) || is_bool($value)) {
|
||||
$this->andWhere('.'.$name.' = :'.$name);
|
||||
$this->setParameter(':'.$name, $value);
|
||||
} elseif (is_string($value)) {
|
||||
$this->andWhere('.'.$name.' LIKE :'.$name);
|
||||
$this->setParameter(':'.$name, '%'.$value.'%');
|
||||
} else {
|
||||
if ('category' === $name) {
|
||||
$this->inCategory($value);
|
||||
}
|
||||
}
|
||||
if ('category' === $name) {
|
||||
$this->inCategory($value);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function search(?string $keywords, ?string $tag)
|
||||
|
|
Loading…
Reference in a new issue