Refactor ProjectActivity model to use Filter and Formatter interface
This commit is contained in:
38
app/Filter/ProjectActivityProjectIdFilter.php
Normal file
38
app/Filter/ProjectActivityProjectIdFilter.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Filter;
|
||||
|
||||
use Kanboard\Core\Filter\FilterInterface;
|
||||
use Kanboard\Model\ProjectActivity;
|
||||
|
||||
/**
|
||||
* Filter activity events by projectId
|
||||
*
|
||||
* @package filter
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class ProjectActivityProjectIdFilter extends BaseFilter implements FilterInterface
|
||||
{
|
||||
/**
|
||||
* Get search attribute
|
||||
*
|
||||
* @access public
|
||||
* @return string[]
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
return array('project_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply filter
|
||||
*
|
||||
* @access public
|
||||
* @return FilterInterface
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
$this->query->eq(ProjectActivity::TABLE.'.project_id', $this->value);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
43
app/Filter/ProjectActivityProjectIdsFilter.php
Normal file
43
app/Filter/ProjectActivityProjectIdsFilter.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Filter;
|
||||
|
||||
use Kanboard\Core\Filter\FilterInterface;
|
||||
use Kanboard\Model\ProjectActivity;
|
||||
|
||||
/**
|
||||
* Filter activity events by projectIds
|
||||
*
|
||||
* @package filter
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class ProjectActivityProjectIdsFilter extends BaseFilter implements FilterInterface
|
||||
{
|
||||
/**
|
||||
* Get search attribute
|
||||
*
|
||||
* @access public
|
||||
* @return string[]
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
return array('project_ids');
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply filter
|
||||
*
|
||||
* @access public
|
||||
* @return FilterInterface
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
if (empty($this->value)) {
|
||||
$this->query->eq(ProjectActivity::TABLE.'.project_id', 0);
|
||||
} else {
|
||||
$this->query->in(ProjectActivity::TABLE.'.project_id', $this->value);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
38
app/Filter/ProjectActivityTaskIdFilter.php
Normal file
38
app/Filter/ProjectActivityTaskIdFilter.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Filter;
|
||||
|
||||
use Kanboard\Core\Filter\FilterInterface;
|
||||
use Kanboard\Model\ProjectActivity;
|
||||
|
||||
/**
|
||||
* Filter activity events by taskId
|
||||
*
|
||||
* @package filter
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class ProjectActivityTaskIdFilter extends BaseFilter implements FilterInterface
|
||||
{
|
||||
/**
|
||||
* Get search attribute
|
||||
*
|
||||
* @access public
|
||||
* @return string[]
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
return array('task_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply filter
|
||||
*
|
||||
* @access public
|
||||
* @return FilterInterface
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
$this->query->eq(ProjectActivity::TABLE.'.task_id', $this->value);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
38
app/Filter/ProjectActivityTaskTitleFilter.php
Normal file
38
app/Filter/ProjectActivityTaskTitleFilter.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Filter;
|
||||
|
||||
use Kanboard\Core\Filter\FilterInterface;
|
||||
use Kanboard\Model\Task;
|
||||
|
||||
/**
|
||||
* Filter activity events by task title
|
||||
*
|
||||
* @package filter
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class ProjectActivityTaskTitleFilter extends BaseFilter implements FilterInterface
|
||||
{
|
||||
/**
|
||||
* Get search attribute
|
||||
*
|
||||
* @access public
|
||||
* @return string[]
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
return array('title');
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply filter
|
||||
*
|
||||
* @access public
|
||||
* @return FilterInterface
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
$this->query->ilike(Task::TABLE.'.title', '%'.$this->value.'%');
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user