upgraded to symfony 4 #74 (#81)

This commit is contained in:
Kevin Papst
2018-01-12 20:39:07 +01:00
committed by GitHub
parent c011b83b73
commit a87355695e
232 changed files with 5260 additions and 4231 deletions

View File

@@ -0,0 +1,71 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Repository\Query;
use App\Entity\Customer;
use App\Entity\Project;
/**
* Can be used for advanced queries with the: ActivityRepository
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class ActivityQuery extends VisibilityQuery
{
/**
* @var Project
*/
protected $project;
/**
* @var Customer
*/
protected $customer;
/**
* @return Customer
*/
public function getCustomer()
{
return $this->customer;
}
/**
* @param Customer $customer
* @return $this
*/
public function setCustomer(Customer $customer = null)
{
$this->customer = $customer;
return $this;
}
/**
* @return Project
*/
public function getProject()
{
return $this->project;
}
/**
* @param Project $project
* @return $this
*/
public function setProject(Project $project = null)
{
$this->project = $project;
return $this;
}
}

View File

@@ -0,0 +1,172 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Repository\Query;
/**
* Base class for advanced Repository queries.
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class BaseQuery
{
const ORDER_ASC = 'ASC';
const ORDER_DESC = 'DESC';
const DEFAULT_PAGESIZE = 25;
const DEFAULT_PAGE = 1;
const RESULT_TYPE_PAGER = 'PagerFanta';
const RESULT_TYPE_QUERYBUILDER = 'QueryBuilder';
/**
* @var \stdClass
*/
protected $hiddenEntity;
/**
* @var int
*/
protected $page = self::DEFAULT_PAGE;
/**
* @var int
*/
protected $pageSize = self::DEFAULT_PAGESIZE;
/**
* @var string
*/
protected $orderBy = 'id';
/**
* @var string
*/
protected $order = 'ASC';
/**
* @var string
*/
protected $resultType = self::RESULT_TYPE_PAGER;
/**
* @return int
*/
public function getPage()
{
return $this->page;
}
/**
* @param int $page
* @return $this
*/
public function setPage($page)
{
$this->page = (int)$page;
return $this;
}
/**
* @return int
*/
public function getPageSize()
{
return $this->pageSize;
}
/**
* @param int $pageSize
* @return $this
*/
public function setPageSize($pageSize)
{
if (!empty($pageSize) && (int)$pageSize > 0) {
$this->pageSize = (int)$pageSize;
}
return $this;
}
/**
* @return string
*/
public function getOrderBy()
{
return $this->orderBy;
}
/**
* You need to validate carefully if this value is used from a user-input.
*
* @param string $orderBy
* @return $this
*/
public function setOrderBy($orderBy)
{
$this->orderBy = $orderBy;
return $this;
}
/**
* @return string
*/
public function getOrder()
{
return $this->order;
}
/**
* @param string $order
* @return $this
*/
public function setOrder($order)
{
if (in_array($order, [self::ORDER_ASC, self::ORDER_DESC])) {
$this->order = $order;
}
return $this;
}
/**
* @return string
*/
public function getResultType()
{
return $this->resultType;
}
/**
* @param string $resultType
* @return $this
*/
public function setResultType($resultType)
{
if (in_array($resultType, [self::RESULT_TYPE_PAGER, self::RESULT_TYPE_QUERYBUILDER])) {
$this->resultType = $resultType;
}
return $this;
}
/**
* @return \stdClass
*/
public function getHiddenEntity()
{
return $this->hiddenEntity;
}
/**
* @param \stdClass $hiddenEntity
* @return BaseQuery
*/
public function setHiddenEntity($hiddenEntity)
{
$this->hiddenEntity = $hiddenEntity;
return $this;
}
}

View File

@@ -0,0 +1,21 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Repository\Query;
/**
* Can be used for advanced queries with the: CustomerRepository
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class CustomerQuery extends VisibilityQuery
{
}

View File

@@ -0,0 +1,46 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Repository\Query;
use App\Entity\Customer;
/**
* Can be used for advanced queries with the: ProjectRepository
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class ProjectQuery extends VisibilityQuery
{
/**
* @var Customer
*/
protected $customer;
/**
* @return Customer
*/
public function getCustomer()
{
return $this->customer;
}
/**
* @param Customer $customer
* @return $this
*/
public function setCustomer(Customer $customer = null)
{
$this->customer = $customer;
return $this;
}
}

View File

@@ -0,0 +1,161 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Repository\Query;
use App\Entity\User;
use App\Repository\Query\BaseQuery;
use App\Entity\Activity;
use App\Entity\Customer;
use App\Entity\Project;
/**
* Can be used for advanced timesheet repository queries.
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class TimesheetQuery extends BaseQuery
{
const STATE_ALL = 0;
const STATE_RUNNING = 1;
const STATE_STOPPED = 2;
/**
* Overwritten for different default order
* @var string
*/
protected $order = self::ORDER_DESC;
/**
* Overwritten for different default order
* @var string
*/
protected $orderBy = 'begin';
/**
* @var User
*/
protected $user;
/**
* @var Activity
*/
protected $activity;
/**
* @var Project
*/
protected $project;
/**
* @var Customer
*/
protected $customer;
/**
* @var int
*/
protected $state = self::STATE_ALL;
/**
* @return User
*/
public function getUser()
{
return $this->user;
}
/**
* @param User $user
* @return TimesheetQuery
*/
public function setUser(User $user = null)
{
$this->user = $user;
return $this;
}
/**
* Activity overwrites: setProject() and setCustomer()
*
* @return Activity
*/
public function getActivity()
{
return $this->activity;
}
/**
* @param Activity $activity
* @return TimesheetQuery
*/
public function setActivity(Activity $activity = null)
{
$this->activity = $activity;
return $this;
}
/**
* @return Project
*/
public function getProject()
{
return $this->project;
}
/**
* Project overwrites: setCustomer()
* Is overwritten by: setActivity()
*
* @param Project $project
* @return TimesheetQuery
*/
public function setProject(Project $project = null)
{
$this->project = $project;
return $this;
}
/**
* @return Customer
*/
public function getCustomer()
{
return $this->customer;
}
/**
* Project overwrites: none
* Is overwritten by: setActivity() and setProject()
*
* @param Customer $customer
* @return TimesheetQuery
*/
public function setCustomer(Customer $customer = null)
{
$this->customer = $customer;
return $this;
}
/**
* @return int
*/
public function getState()
{
return $this->state;
}
/**
* @param int $state
* @return TimesheetQuery
*/
public function setState($state)
{
if (in_array($state, [self::STATE_ALL, self::STATE_RUNNING, self::STATE_STOPPED], true)) {
$this->state = $state;
}
return $this;
}
}

View File

@@ -0,0 +1,46 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Repository\Query;
/**
* Can be used for advanced queries with the: UserRepository
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class UserQuery extends VisibilityQuery
{
/**
* @var string
*/
protected $role;
/**
* @return string
*/
public function getRole()
{
return $this->role;
}
/**
* @param string $role
* @return UserQuery
*/
public function setRole($role)
{
if (strpos($role, 'ROLE_') !== false || $role === null) {
$this->role = $role;
}
return $this;
}
}

View File

@@ -0,0 +1,80 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Repository\Query;
/**
* Query class for Repositories with a visibility field.
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class VisibilityQuery extends BaseQuery
{
const SHOW_VISIBLE = 1;
const SHOW_HIDDEN = 2;
const SHOW_BOTH = 3;
/**
* @var integer
*/
protected $visibility = self::SHOW_VISIBLE;
/**
* @var bool
*/
protected $exclusiveVisibility = false;
/**
* @return int
*/
public function getVisibility()
{
return $this->visibility;
}
/**
* @param int $visibility
* @return $this
*/
public function setVisibility($visibility)
{
if (!is_int($visibility) && $visibility != (int) $visibility) {
return $this;
}
$visibility = (int) $visibility;
if (in_array($visibility, [self::SHOW_BOTH, self::SHOW_VISIBLE, self::SHOW_HIDDEN], true)) {
$this->visibility = $visibility;
}
return $this;
}
/**
* @return bool
*/
public function isExclusiveVisibility()
{
return $this->exclusiveVisibility;
}
/**
* If set to true, this will ONLY filter the visibility on the main queried object.
*
* @param bool $exclusiveVisibility
* @return $this
*/
public function setExclusiveVisibility($exclusiveVisibility)
{
$this->exclusiveVisibility = (bool) $exclusiveVisibility;
return $this;
}
}