Made ARG_QUERY optional

This commit is contained in:
Marcin Kurczewski 2014-05-13 14:06:09 +02:00
parent ae12fdeaec
commit 561ebd5508
5 changed files with 20 additions and 12 deletions

View file

@ -19,7 +19,9 @@ class GetLogJob extends AbstractJob implements IPagedJob
$pageSize = $this->pager->getPageSize();
$page = $this->pager->getPageNumber();
$name = $this->getArgument(JobArgs::ARG_LOG_ID);
$query = $this->getArgument(JobArgs::ARG_QUERY);
$query = $this->hasArgument(JobArgs::ARG_QUERY)
? $this->getArgument(JobArgs::ARG_QUERY)
: '';
//parse input
$page = max(1, intval($page));
@ -53,7 +55,7 @@ class GetLogJob extends AbstractJob implements IPagedJob
return JobArgs::Conjunction(
$this->pager->getRequiredArguments(),
JobArgs::ARG_LOG_ID,
JobArgs::ARG_QUERY);
JobArgs::Optional(JobArgs::ARG_QUERY));
}
public function getRequiredPrivileges()

View file

@ -18,7 +18,9 @@ class ListPostsJob extends AbstractJob implements IPagedJob
{
$pageSize = $this->pager->getPageSize();
$page = $this->pager->getPageNumber();
$query = $this->getArgument(JobArgs::ARG_QUERY);
$query = $this->hasArgument(JobArgs::ARG_QUERY)
? $this->getArgument(JobArgs::ARG_QUERY)
: '';
$posts = PostSearchService::getEntities($query, $pageSize, $page);
$postCount = PostSearchService::getEntityCount($query);
@ -32,7 +34,7 @@ class ListPostsJob extends AbstractJob implements IPagedJob
{
return JobArgs::Conjunction(
$this->pager->getRequiredArguments(),
JobArgs::ARG_QUERY);
JobArgs::Optional(JobArgs::ARG_QUERY));
}
public function getRequiredPrivileges()

View file

@ -18,7 +18,9 @@ class ListTagsJob extends AbstractJob implements IPagedJob
{
$pageSize = $this->pager->getPageSize();
$page = $this->pager->getPageNumber();
$query = $this->getArgument(JobArgs::ARG_QUERY);
$query = $this->hasArgument(JobArgs::ARG_QUERY)
? $this->getArgument(JobArgs::ARG_QUERY)
: '';
$tags = TagSearchService::getEntities($query, $pageSize, $page);
$tagCount = TagSearchService::getEntityCount($query);
@ -30,7 +32,7 @@ class ListTagsJob extends AbstractJob implements IPagedJob
{
return JobArgs::Conjunction(
$this->pager->getRequiredArguments(),
JobArgs::ARG_QUERY);
JobArgs::Optional(JobArgs::ARG_QUERY));
}
public function getRequiredPrivileges()

View file

@ -18,7 +18,9 @@ class ListUsersJob extends AbstractJob implements IPagedJob
{
$pageSize = $this->pager->getPageSize();
$page = $this->pager->getPageNumber();
$filter = $this->getArgument(JobArgs::ARG_QUERY);
$filter = $this->hasArgument(JobArgs::ARG_QUERY)
? $this->getArgument(JobArgs::ARG_QUERY)
: '';
$users = UserSearchService::getEntities($filter, $pageSize, $page);
$userCount = UserSearchService::getEntityCount($filter);
@ -30,7 +32,7 @@ class ListUsersJob extends AbstractJob implements IPagedJob
{
return JobArgs::Conjunction(
$this->pager->getRequiredArguments(),
JobArgs::ARG_QUERY);
JobArgs::Optional(JobArgs::ARG_QUERY));
}
public function getRequiredPrivileges()

View file

@ -179,7 +179,7 @@ class ApiArgumentTest extends AbstractFullApiTest
{
$this->testArguments(new GetLogJob(),
JobArgs::Conjunction(
JobArgs::ARG_QUERY,
JobArgs::Optional(JobArgs::ARG_QUERY),
JobArgs::ARG_LOG_ID,
JobArgs::Optional(JobArgs::ARG_PAGE_NUMBER)));
}
@ -227,7 +227,7 @@ class ApiArgumentTest extends AbstractFullApiTest
{
$this->testArguments(new ListPostsJob(),
JobArgs::Conjunction(
JobArgs::ARG_QUERY,
JobArgs::Optional(JobArgs::ARG_QUERY),
JobArgs::Optional(JobArgs::ARG_PAGE_NUMBER)));
}
@ -244,7 +244,7 @@ class ApiArgumentTest extends AbstractFullApiTest
{
$this->testArguments(new ListTagsJob(),
JobArgs::Conjunction(
JobArgs::ARG_QUERY,
JobArgs::Optional(JobArgs::ARG_QUERY),
JobArgs::Optional(JobArgs::ARG_PAGE_NUMBER)));
}
@ -252,7 +252,7 @@ class ApiArgumentTest extends AbstractFullApiTest
{
$this->testArguments(new ListUsersJob(),
JobArgs::Conjunction(
JobArgs::ARG_QUERY,
JobArgs::Optional(JobArgs::ARG_QUERY),
JobArgs::Optional(JobArgs::ARG_PAGE_NUMBER)));
}