API improvements (#1826)
This commit is contained in:
@@ -41,6 +41,11 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
*/
|
||||
class ActivityController extends BaseApiController
|
||||
{
|
||||
public const GROUPS_ENTITY = ['Default', 'Entity', 'Activity', 'Activity_Entity'];
|
||||
public const GROUPS_FORM = ['Default', 'Entity', 'Activity'];
|
||||
public const GROUPS_COLLECTION = ['Default', 'Collection', 'Activity'];
|
||||
public const GROUPS_RATE = ['Default', 'Entity', 'Activity_Rate'];
|
||||
|
||||
/**
|
||||
* @var ActivityRepository
|
||||
*/
|
||||
@@ -132,7 +137,7 @@ class ActivityController extends BaseApiController
|
||||
|
||||
$data = $this->repository->getActivitiesForQuery($query);
|
||||
$view = new View($data, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Collection', 'Activity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_COLLECTION);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -165,7 +170,7 @@ class ActivityController extends BaseApiController
|
||||
}
|
||||
|
||||
$view = new View($data, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Activity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -212,13 +217,13 @@ class ActivityController extends BaseApiController
|
||||
$this->repository->saveActivity($activity);
|
||||
|
||||
$view = new View($activity, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Activity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
|
||||
$view = new View($form);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Activity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_FORM);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -275,7 +280,7 @@ class ActivityController extends BaseApiController
|
||||
|
||||
if (false === $form->isValid()) {
|
||||
$view = new View($form, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Activity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_FORM);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -283,7 +288,7 @@ class ActivityController extends BaseApiController
|
||||
$this->repository->saveActivity($activity);
|
||||
|
||||
$view = new View($activity, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Activity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -336,7 +341,7 @@ class ActivityController extends BaseApiController
|
||||
$this->repository->saveActivity($activity);
|
||||
|
||||
$view = new View($activity, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Activity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -379,7 +384,7 @@ class ActivityController extends BaseApiController
|
||||
$rates = $this->activityRateRepository->getRatesForActivity($activity);
|
||||
|
||||
$view = new View($rates, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'ActivityRate']);
|
||||
$view->getContext()->setGroups(self::GROUPS_RATE);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -490,7 +495,7 @@ class ActivityController extends BaseApiController
|
||||
|
||||
if (false === $form->isValid()) {
|
||||
$view = new View($form, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'ActivityRate']);
|
||||
$view->getContext()->setGroups(self::GROUPS_RATE);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -498,7 +503,7 @@ class ActivityController extends BaseApiController
|
||||
$this->activityRateRepository->saveRate($rate);
|
||||
|
||||
$view = new View($rate, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'ActivityRate']);
|
||||
$view->getContext()->setGroups(self::GROUPS_RATE);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\API;
|
||||
|
||||
use App\API\Model\I18n;
|
||||
use App\API\Model\I18nConfig;
|
||||
use App\API\Model\TimesheetConfig;
|
||||
use App\Configuration\LanguageFormattings;
|
||||
use App\Configuration\TimesheetConfiguration;
|
||||
@@ -19,6 +19,7 @@ use App\Entity\User;
|
||||
use FOS\RestBundle\Controller\Annotations as Rest;
|
||||
use FOS\RestBundle\View\View;
|
||||
use FOS\RestBundle\View\ViewHandlerInterface;
|
||||
use Nelmio\ApiDocBundle\Annotation\Model;
|
||||
use Nelmio\ApiDocBundle\Annotation\Security as ApiSecurity;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
||||
use Swagger\Annotations as SWG;
|
||||
@@ -44,11 +45,6 @@ final class ConfigurationController extends BaseApiController
|
||||
*/
|
||||
private $timesheetConfiguration;
|
||||
|
||||
/**
|
||||
* @param ViewHandlerInterface $viewHandler
|
||||
* @param LanguageFormattings $formats
|
||||
* @param TimesheetConfiguration $timesheetConfiguration
|
||||
*/
|
||||
public function __construct(ViewHandlerInterface $viewHandler, LanguageFormattings $formats, TimesheetConfiguration $timesheetConfiguration)
|
||||
{
|
||||
$this->viewHandler = $viewHandler;
|
||||
@@ -62,7 +58,7 @@ final class ConfigurationController extends BaseApiController
|
||||
* @SWG\Response(
|
||||
* response=200,
|
||||
* description="Returns the locale specific configurations for this user",
|
||||
* @SWG\Schema(ref="#/definitions/I18nConfig")
|
||||
* @SWG\Schema(ref=@Model(type=I18nConfig::class))
|
||||
* )
|
||||
*
|
||||
* @Rest\Get(path="/config/i18n")
|
||||
@@ -76,7 +72,7 @@ final class ConfigurationController extends BaseApiController
|
||||
$user = $this->getUser();
|
||||
$locale = $user->getLocale();
|
||||
|
||||
$model = new I18n();
|
||||
$model = new I18nConfig();
|
||||
$model
|
||||
->setFormDateTime($this->formats->getDateTimeTypeFormat($locale))
|
||||
->setFormDate($this->formats->getDateTypeFormat($locale))
|
||||
@@ -99,7 +95,7 @@ final class ConfigurationController extends BaseApiController
|
||||
* @SWG\Response(
|
||||
* response=200,
|
||||
* description="Returns the instance specific timesheet configuration",
|
||||
* @SWG\Schema(ref="#/definitions/TimesheetConfig")
|
||||
* @SWG\Schema(ref=@Model(type=TimesheetConfig::class))
|
||||
* )
|
||||
*
|
||||
* @Rest\Get(path="/config/timesheet")
|
||||
|
||||
@@ -42,6 +42,11 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
*/
|
||||
class CustomerController extends BaseApiController
|
||||
{
|
||||
public const GROUPS_ENTITY = ['Default', 'Entity', 'Customer', 'Customer_Entity'];
|
||||
public const GROUPS_FORM = ['Default', 'Entity', 'Customer'];
|
||||
public const GROUPS_COLLECTION = ['Default', 'Collection', 'Customer'];
|
||||
public const GROUPS_RATE = ['Default', 'Entity', 'Customer_Rate'];
|
||||
|
||||
/**
|
||||
* @var CustomerRepository
|
||||
*/
|
||||
@@ -112,7 +117,7 @@ class CustomerController extends BaseApiController
|
||||
|
||||
$data = $this->repository->getCustomersForQuery($query);
|
||||
$view = new View($data, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Collection', 'Customer']);
|
||||
$view->getContext()->setGroups(self::GROUPS_COLLECTION);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -138,7 +143,7 @@ class CustomerController extends BaseApiController
|
||||
}
|
||||
|
||||
$view = new View($data, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Customer']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -185,13 +190,13 @@ class CustomerController extends BaseApiController
|
||||
$this->repository->saveCustomer($customer);
|
||||
|
||||
$view = new View($customer, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Customer']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
|
||||
$view = new View($form);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Customer']);
|
||||
$view->getContext()->setGroups(self::GROUPS_FORM);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -248,7 +253,7 @@ class CustomerController extends BaseApiController
|
||||
|
||||
if (false === $form->isValid()) {
|
||||
$view = new View($form, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Customer']);
|
||||
$view->getContext()->setGroups(self::GROUPS_FORM);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -256,7 +261,7 @@ class CustomerController extends BaseApiController
|
||||
$this->repository->saveCustomer($customer);
|
||||
|
||||
$view = new View($customer, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Customer']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -309,7 +314,7 @@ class CustomerController extends BaseApiController
|
||||
$this->repository->saveCustomer($customer);
|
||||
|
||||
$view = new View($customer, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Customer']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -352,7 +357,7 @@ class CustomerController extends BaseApiController
|
||||
$rates = $this->customerRateRepository->getRatesForCustomer($customer);
|
||||
|
||||
$view = new View($rates, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'CustomerRate']);
|
||||
$view->getContext()->setGroups(self::GROUPS_RATE);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -463,7 +468,7 @@ class CustomerController extends BaseApiController
|
||||
|
||||
if (false === $form->isValid()) {
|
||||
$view = new View($form, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'CustomerRate']);
|
||||
$view->getContext()->setGroups(self::GROUPS_RATE);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -471,7 +476,7 @@ class CustomerController extends BaseApiController
|
||||
$this->customerRateRepository->saveRate($rate);
|
||||
|
||||
$view = new View($rate, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'CustomerRate']);
|
||||
$view->getContext()->setGroups(self::GROUPS_RATE);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
|
||||
@@ -11,177 +11,127 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\API\Model;
|
||||
|
||||
final class I18n
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @Serializer\ExclusionPolicy("all")
|
||||
*/
|
||||
final class I18nConfig
|
||||
{
|
||||
/**
|
||||
* Format used for 'begin' and 'end'
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="string")
|
||||
*/
|
||||
private $formDateTime = '';
|
||||
/**
|
||||
* Format used for toolbar queries
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="string")
|
||||
*/
|
||||
private $formDate = '';
|
||||
/**
|
||||
* Format used to display date-time values (see PHP function date_format)
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="string")
|
||||
*/
|
||||
private $dateTime = '';
|
||||
/**
|
||||
* Format used to display date values (see PHP function date_format)
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="string")
|
||||
*/
|
||||
private $date = '';
|
||||
/**
|
||||
* Format used to display times (see PHP function date_format)
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="string")
|
||||
*/
|
||||
private $time = '';
|
||||
/**
|
||||
* Format used to display durations (replace: %h with hours, %m with minutes, %s with seconds)
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="string")
|
||||
*/
|
||||
private $duration = '';
|
||||
/**
|
||||
* Whether a twenty-four hour format is used (true) or 12-hours AM/PM format (false)
|
||||
*
|
||||
* @var bool
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="boolean")
|
||||
*/
|
||||
private $is24hours = true;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFormDateTime(): string
|
||||
{
|
||||
return $this->formDateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $formDateTime
|
||||
* @return I18n
|
||||
*/
|
||||
public function setFormDateTime(string $formDateTime)
|
||||
public function setFormDateTime(string $formDateTime): I18nConfig
|
||||
{
|
||||
$this->formDateTime = $formDateTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFormDate(): string
|
||||
{
|
||||
return $this->formDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $formDate
|
||||
* @return I18n
|
||||
*/
|
||||
public function setFormDate(string $formDate)
|
||||
public function setFormDate(string $formDate): I18nConfig
|
||||
{
|
||||
$this->formDate = $formDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDateTime(): string
|
||||
{
|
||||
return $this->dateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dateTime
|
||||
* @return I18n
|
||||
*/
|
||||
public function setDateTime(string $dateTime)
|
||||
public function setDateTime(string $dateTime): I18nConfig
|
||||
{
|
||||
$this->dateTime = $dateTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDate(): string
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $date
|
||||
* @return I18n
|
||||
*/
|
||||
public function setDate(string $date)
|
||||
public function setDate(string $date): I18nConfig
|
||||
{
|
||||
$this->date = $date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDuration(): string
|
||||
{
|
||||
return $this->duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $duration
|
||||
* @return I18n
|
||||
*/
|
||||
public function setDuration(string $duration)
|
||||
public function setDuration(string $duration): I18nConfig
|
||||
{
|
||||
$this->duration = $duration;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTime(): string
|
||||
{
|
||||
return $this->time;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $time
|
||||
* @return I18n
|
||||
*/
|
||||
public function setTime(string $time)
|
||||
public function setTime(string $time): I18nConfig
|
||||
{
|
||||
$this->time = $time;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isIs24hours(): bool
|
||||
{
|
||||
return $this->is24hours;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $is24hours
|
||||
* @return I18n
|
||||
*/
|
||||
public function setIs24hours(bool $is24hours)
|
||||
public function setIs24hours(bool $is24hours): I18nConfig
|
||||
{
|
||||
$this->is24hours = $is24hours;
|
||||
|
||||
@@ -11,53 +11,74 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\API\Model;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @Serializer\ExclusionPolicy("none")
|
||||
*/
|
||||
final class TimesheetConfig
|
||||
{
|
||||
/**
|
||||
* See here: https://www.kimai.org/documentation/timesheet.html#tracking-modes
|
||||
* The time-tracking mode, see also: https://www.kimai.org/documentation/timesheet.html#tracking-modes
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="string")
|
||||
*/
|
||||
private $trackingMode = 'default';
|
||||
/**
|
||||
* Default begin datetime in PHP format
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="string")
|
||||
*/
|
||||
private $defaultBeginTime = 'now';
|
||||
/**
|
||||
* How many running timesheets a user is allowed to have at the same time
|
||||
*
|
||||
* @var int
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="integer")
|
||||
*/
|
||||
private $activeEntriesHardLimit = 1;
|
||||
/**
|
||||
* How many running timesheets a user is allowed before a warning is shown
|
||||
*
|
||||
* @var int
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="integer")
|
||||
*/
|
||||
private $activeEntriesSoftLimit = 1;
|
||||
/**
|
||||
* Whether entries for future times are allowed
|
||||
*
|
||||
* @var bool
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="boolean")
|
||||
*/
|
||||
private $isAllowFutureTimes = true;
|
||||
/**
|
||||
* Whether overlapping entries are allowed
|
||||
*
|
||||
* @var bool
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="boolean")
|
||||
*/
|
||||
private $isAllowOverlapping = true;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTrackingMode(): string
|
||||
{
|
||||
return $this->trackingMode;
|
||||
}
|
||||
|
||||
public function setTrackingMode(string $trackingMode): TimesheetConfig
|
||||
{
|
||||
$this->trackingMode = $trackingMode;
|
||||
@@ -65,11 +86,6 @@ final class TimesheetConfig
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDefaultBeginTime(): string
|
||||
{
|
||||
return $this->defaultBeginTime;
|
||||
}
|
||||
|
||||
public function setDefaultBeginTime(string $defaultBeginTime): TimesheetConfig
|
||||
{
|
||||
$this->defaultBeginTime = $defaultBeginTime;
|
||||
@@ -77,11 +93,6 @@ final class TimesheetConfig
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getActiveEntriesHardLimit(): int
|
||||
{
|
||||
return $this->activeEntriesHardLimit;
|
||||
}
|
||||
|
||||
public function setActiveEntriesHardLimit(int $activeEntriesHardLimit): TimesheetConfig
|
||||
{
|
||||
$this->activeEntriesHardLimit = $activeEntriesHardLimit;
|
||||
@@ -89,11 +100,6 @@ final class TimesheetConfig
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getActiveEntriesSoftLimit(): int
|
||||
{
|
||||
return $this->activeEntriesSoftLimit;
|
||||
}
|
||||
|
||||
public function setActiveEntriesSoftLimit(int $activeEntriesSoftLimit): TimesheetConfig
|
||||
{
|
||||
$this->activeEntriesSoftLimit = $activeEntriesSoftLimit;
|
||||
@@ -101,11 +107,6 @@ final class TimesheetConfig
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isAllowFutureTimes(): bool
|
||||
{
|
||||
return $this->isAllowFutureTimes;
|
||||
}
|
||||
|
||||
public function setIsAllowFutureTimes(bool $isAllowFutureTimes): TimesheetConfig
|
||||
{
|
||||
$this->isAllowFutureTimes = $isAllowFutureTimes;
|
||||
@@ -113,11 +114,6 @@ final class TimesheetConfig
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isAllowOverlapping(): bool
|
||||
{
|
||||
return $this->isAllowOverlapping;
|
||||
}
|
||||
|
||||
public function setIsAllowOverlapping(bool $isAllowOverlapping): TimesheetConfig
|
||||
{
|
||||
$this->isAllowOverlapping = $isAllowOverlapping;
|
||||
|
||||
@@ -12,37 +12,61 @@ declare(strict_types=1);
|
||||
namespace App\API\Model;
|
||||
|
||||
use App\Constants;
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @Serializer\ExclusionPolicy("all")
|
||||
*/
|
||||
class Version
|
||||
{
|
||||
/**
|
||||
* Kimai Version, eg. "1.9"
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="string")
|
||||
*/
|
||||
protected $version = Constants::VERSION;
|
||||
/**
|
||||
* Candidate: either "prod" or "dev"
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="string")
|
||||
*/
|
||||
protected $candidate = Constants::STATUS;
|
||||
/**
|
||||
* Full version including status, eg: "1.9-prod"
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="string")
|
||||
*/
|
||||
protected $semver = Constants::VERSION . '-' . Constants::STATUS;
|
||||
/**
|
||||
* The version name
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="string")
|
||||
*/
|
||||
protected $name = Constants::NAME;
|
||||
/**
|
||||
* A full copyright notice
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Expose()
|
||||
* @Serializer\Groups({"Default"})
|
||||
* @Serializer\Type(name="string")
|
||||
*/
|
||||
protected $copyright = Constants::SOFTWARE . ' - ' . Constants::VERSION . ' ' . Constants::STATUS . ' (' . Constants::NAME . ') by Kevin Papst and contributors.';
|
||||
}
|
||||
|
||||
@@ -45,6 +45,11 @@ use Symfony\Component\Validator\Constraints;
|
||||
*/
|
||||
class ProjectController extends BaseApiController
|
||||
{
|
||||
public const GROUPS_ENTITY = ['Default', 'Entity', 'Project', 'Project_Entity'];
|
||||
public const GROUPS_FORM = ['Default', 'Entity', 'Project'];
|
||||
public const GROUPS_COLLECTION = ['Default', 'Collection', 'Project'];
|
||||
public const GROUPS_RATE = ['Default', 'Entity', 'Project_Rate'];
|
||||
|
||||
/**
|
||||
* @var ProjectRepository
|
||||
*/
|
||||
@@ -159,7 +164,7 @@ class ProjectController extends BaseApiController
|
||||
|
||||
$data = $this->repository->getProjectsForQuery($query);
|
||||
$view = new View($data, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Collection', 'Project']);
|
||||
$view->getContext()->setGroups(self::GROUPS_COLLECTION);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -185,7 +190,7 @@ class ProjectController extends BaseApiController
|
||||
}
|
||||
|
||||
$view = new View($data, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Project']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -233,13 +238,13 @@ class ProjectController extends BaseApiController
|
||||
$this->repository->saveProject($project);
|
||||
|
||||
$view = new View($project, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Project']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
|
||||
$view = new View($form);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Project']);
|
||||
$view->getContext()->setGroups(self::GROUPS_FORM);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -297,7 +302,7 @@ class ProjectController extends BaseApiController
|
||||
|
||||
if (false === $form->isValid()) {
|
||||
$view = new View($form, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Project']);
|
||||
$view->getContext()->setGroups(self::GROUPS_FORM);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -305,7 +310,7 @@ class ProjectController extends BaseApiController
|
||||
$this->repository->saveProject($project);
|
||||
|
||||
$view = new View($project, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Project']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -358,7 +363,7 @@ class ProjectController extends BaseApiController
|
||||
$this->repository->saveProject($project);
|
||||
|
||||
$view = new View($project, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Project']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -401,7 +406,7 @@ class ProjectController extends BaseApiController
|
||||
$rates = $this->projectRateRepository->getRatesForProject($project);
|
||||
|
||||
$view = new View($rates, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'ProjectRate']);
|
||||
$view->getContext()->setGroups(self::GROUPS_RATE);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -512,7 +517,7 @@ class ProjectController extends BaseApiController
|
||||
|
||||
if (false === $form->isValid()) {
|
||||
$view = new View($form, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'ProjectRate']);
|
||||
$view->getContext()->setGroups(self::GROUPS_RATE);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -520,7 +525,7 @@ class ProjectController extends BaseApiController
|
||||
$this->projectRateRepository->saveRate($rate);
|
||||
|
||||
$view = new View($rate, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'ProjectRate']);
|
||||
$view->getContext()->setGroups(self::GROUPS_RATE);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
|
||||
@@ -28,11 +28,8 @@ class StatusController extends BaseApiController
|
||||
/**
|
||||
* @var ViewHandlerInterface
|
||||
*/
|
||||
protected $viewHandler;
|
||||
private $viewHandler;
|
||||
|
||||
/**
|
||||
* @param ViewHandlerInterface $viewHandler
|
||||
*/
|
||||
public function __construct(ViewHandlerInterface $viewHandler)
|
||||
{
|
||||
$this->viewHandler = $viewHandler;
|
||||
|
||||
@@ -32,22 +32,21 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
*
|
||||
* @Security("is_granted('IS_AUTHENTICATED_REMEMBERED')")
|
||||
*/
|
||||
class TagController extends BaseApiController
|
||||
final class TagController extends BaseApiController
|
||||
{
|
||||
public const GROUPS_COLLECTION = ['Default', 'Collection', 'Tag'];
|
||||
public const GROUPS_ENTITY = ['Default', 'Entity', 'Tag'];
|
||||
public const GROUPS_FORM = ['Default', 'Entity', 'Tag'];
|
||||
|
||||
/**
|
||||
* @var TagRepository
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
private $repository;
|
||||
/**
|
||||
* @var ViewHandlerInterface
|
||||
*/
|
||||
protected $viewHandler;
|
||||
private $viewHandler;
|
||||
|
||||
/**
|
||||
* @param ViewHandlerInterface $viewHandler
|
||||
* @param TagRepository $repository
|
||||
*/
|
||||
public function __construct(ViewHandlerInterface $viewHandler, TagRepository $repository)
|
||||
{
|
||||
$this->viewHandler = $viewHandler;
|
||||
@@ -78,7 +77,7 @@ class TagController extends BaseApiController
|
||||
$data = $this->repository->findAllTagNames($filter);
|
||||
|
||||
$view = new View($data, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Collection', 'Tag']);
|
||||
$view->getContext()->setGroups(self::GROUPS_COLLECTION);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -120,13 +119,13 @@ class TagController extends BaseApiController
|
||||
$this->repository->saveTag($tag);
|
||||
|
||||
$view = new View($tag, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Tag']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
|
||||
$view = new View($form);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Tag']);
|
||||
$view->getContext()->setGroups(self::GROUPS_FORM);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -137,7 +136,7 @@ class TagController extends BaseApiController
|
||||
* @SWG\Delete(
|
||||
* @SWG\Response(
|
||||
* response=204,
|
||||
* description="Delete one tag"
|
||||
* description="HTTP code 204 for a successful delete"
|
||||
* ),
|
||||
* )
|
||||
* @SWG\Parameter(
|
||||
|
||||
@@ -39,6 +39,10 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
*/
|
||||
final class TeamController extends BaseApiController
|
||||
{
|
||||
public const GROUPS_ENTITY = ['Default', 'Entity', 'Team', 'Team_Entity'];
|
||||
public const GROUPS_FORM = ['Default', 'Entity', 'Team', 'Team_Entity'];
|
||||
public const GROUPS_COLLECTION = ['Default', 'Collection', 'Team'];
|
||||
|
||||
/**
|
||||
* @var TeamRepository
|
||||
*/
|
||||
@@ -76,7 +80,7 @@ final class TeamController extends BaseApiController
|
||||
$data = $this->repository->findAll();
|
||||
|
||||
$view = new View($data, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Collection', 'Team']);
|
||||
$view->getContext()->setGroups(self::GROUPS_COLLECTION);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -104,7 +108,7 @@ final class TeamController extends BaseApiController
|
||||
}
|
||||
|
||||
$view = new View($data, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Team', 'Team_Entity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -154,7 +158,7 @@ final class TeamController extends BaseApiController
|
||||
* @SWG\Response(
|
||||
* response=200,
|
||||
* description="Returns the new created team",
|
||||
* @SWG\Schema(ref="#/definitions/TeamEntity",),
|
||||
* @SWG\Schema(ref="#/definitions/TeamEntity"),
|
||||
* )
|
||||
* )
|
||||
* @SWG\Parameter(
|
||||
@@ -186,13 +190,13 @@ final class TeamController extends BaseApiController
|
||||
$this->repository->saveTeam($team);
|
||||
|
||||
$view = new View($team, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Team_Entity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
|
||||
$view = new View($form);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Team_Entity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_FORM);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -243,7 +247,7 @@ final class TeamController extends BaseApiController
|
||||
|
||||
if (false === $form->isValid()) {
|
||||
$view = new View($form, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Team_Entity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_FORM);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -251,7 +255,7 @@ final class TeamController extends BaseApiController
|
||||
$this->repository->saveTeam($team);
|
||||
|
||||
$view = new View($team, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Team_Entity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -314,7 +318,7 @@ final class TeamController extends BaseApiController
|
||||
$this->repository->saveTeam($team);
|
||||
|
||||
$view = new View($team, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Team_Entity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -377,7 +381,7 @@ final class TeamController extends BaseApiController
|
||||
$this->repository->saveTeam($team);
|
||||
|
||||
$view = new View($team, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Team_Entity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -440,7 +444,7 @@ final class TeamController extends BaseApiController
|
||||
$this->repository->saveTeam($team);
|
||||
|
||||
$view = new View($team, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Team_Entity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -499,7 +503,7 @@ final class TeamController extends BaseApiController
|
||||
$this->repository->saveTeam($team);
|
||||
|
||||
$view = new View($team, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Team_Entity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -562,7 +566,7 @@ final class TeamController extends BaseApiController
|
||||
$this->repository->saveTeam($team);
|
||||
|
||||
$view = new View($team, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Team_Entity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -621,7 +625,7 @@ final class TeamController extends BaseApiController
|
||||
$this->repository->saveTeam($team);
|
||||
|
||||
$view = new View($team, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Team_Entity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
|
||||
@@ -51,6 +51,11 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
*/
|
||||
class TimesheetController extends BaseApiController
|
||||
{
|
||||
public const GROUPS_ENTITY = ['Default', 'Entity', 'Timesheet', 'Timesheet_Entity', 'Not_Expanded'];
|
||||
public const GROUPS_FORM = ['Default', 'Entity', 'Timesheet', 'Not_Expanded'];
|
||||
public const GROUPS_COLLECTION = ['Default', 'Collection', 'Timesheet', 'Not_Expanded'];
|
||||
public const GROUPS_COLLECTION_FULL = ['Default', 'Collection', 'Timesheet', 'Expanded'];
|
||||
|
||||
/**
|
||||
* @var TimesheetRepository
|
||||
*/
|
||||
@@ -266,9 +271,9 @@ class TimesheetController extends BaseApiController
|
||||
|
||||
$view = new View($data, 200);
|
||||
if ('true' === $paramFetcher->get('full')) {
|
||||
$view->getContext()->setGroups(['Default', 'Subresource', 'Timesheet']);
|
||||
$view->getContext()->setGroups(self::GROUPS_COLLECTION_FULL);
|
||||
} else {
|
||||
$view->getContext()->setGroups(['Default', 'Collection', 'Timesheet']);
|
||||
$view->getContext()->setGroups(self::GROUPS_COLLECTION);
|
||||
}
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
@@ -308,7 +313,7 @@ class TimesheetController extends BaseApiController
|
||||
}
|
||||
|
||||
$view = new View($data, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Timesheet']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -368,13 +373,13 @@ class TimesheetController extends BaseApiController
|
||||
}
|
||||
|
||||
$view = new View($timesheet, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Timesheet']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
|
||||
$view = new View($form);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Timesheet']);
|
||||
$view->getContext()->setGroups(self::GROUPS_FORM);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -438,7 +443,7 @@ class TimesheetController extends BaseApiController
|
||||
|
||||
if (false === $form->isValid()) {
|
||||
$view = new View($form, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Timesheet']);
|
||||
$view->getContext()->setGroups(self::GROUPS_FORM);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -446,7 +451,7 @@ class TimesheetController extends BaseApiController
|
||||
$this->service->updateTimesheet($timesheet);
|
||||
|
||||
$view = new View($timesheet, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Timesheet']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -498,7 +503,7 @@ class TimesheetController extends BaseApiController
|
||||
* description="Returns the collection of recent user activities (always the latest entry of a unique working set grouped by customer, project and activity)",
|
||||
* @SWG\Schema(
|
||||
* type="array",
|
||||
* @SWG\Items(ref="#/definitions/TimesheetSubCollection")
|
||||
* @SWG\Items(ref="#/definitions/TimesheetCollectionExpanded")
|
||||
* )
|
||||
* )
|
||||
*
|
||||
@@ -535,7 +540,7 @@ class TimesheetController extends BaseApiController
|
||||
$data = $this->repository->getRecentActivities($user, $begin, $limit);
|
||||
|
||||
$view = new View($data, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Subresource', 'Timesheet']);
|
||||
$view->getContext()->setGroups(self::GROUPS_COLLECTION_FULL);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -548,7 +553,7 @@ class TimesheetController extends BaseApiController
|
||||
* description="Returns the collection of active timesheet records for the current user",
|
||||
* @SWG\Schema(
|
||||
* type="array",
|
||||
* @SWG\Items(ref="#/definitions/TimesheetSubCollection")
|
||||
* @SWG\Items(ref="#/definitions/TimesheetCollectionExpanded")
|
||||
* )
|
||||
* )
|
||||
*
|
||||
@@ -565,7 +570,7 @@ class TimesheetController extends BaseApiController
|
||||
$data = $this->repository->getActiveEntries($user);
|
||||
|
||||
$view = new View($data, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Subresource', 'Timesheet']);
|
||||
$view->getContext()->setGroups(self::GROUPS_COLLECTION_FULL);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -604,7 +609,7 @@ class TimesheetController extends BaseApiController
|
||||
$this->service->stopTimesheet($timesheet);
|
||||
|
||||
$view = new View($timesheet, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Timesheet']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -687,7 +692,7 @@ class TimesheetController extends BaseApiController
|
||||
$this->service->saveNewTimesheet($copyTimesheet);
|
||||
|
||||
$view = new View($copyTimesheet, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Timesheet']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -728,7 +733,7 @@ class TimesheetController extends BaseApiController
|
||||
$this->service->saveNewTimesheet($copyTimesheet);
|
||||
|
||||
$view = new View($copyTimesheet, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Timesheet']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -771,7 +776,7 @@ class TimesheetController extends BaseApiController
|
||||
$this->service->updateTimesheet($timesheet);
|
||||
|
||||
$view = new View($timesheet, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Timesheet']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -824,7 +829,7 @@ class TimesheetController extends BaseApiController
|
||||
$this->service->updateTimesheet($timesheet);
|
||||
|
||||
$view = new View($timesheet, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'Timesheet']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,10 @@ use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
||||
*/
|
||||
final class UserController extends BaseApiController
|
||||
{
|
||||
public const GROUPS_ENTITY = ['Default', 'Entity', 'User', 'User_Entity'];
|
||||
public const GROUPS_FORM = ['Default', 'Entity', 'User', 'User_Entity'];
|
||||
public const GROUPS_COLLECTION = ['Default', 'Collection', 'User'];
|
||||
|
||||
/**
|
||||
* @var UserRepository
|
||||
*/
|
||||
@@ -56,10 +60,6 @@ final class UserController extends BaseApiController
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* @param ViewHandlerInterface $viewHandler
|
||||
* @param UserRepository $repository
|
||||
*/
|
||||
public function __construct(ViewHandlerInterface $viewHandler, UserRepository $repository, UserPasswordEncoderInterface $encoder, FormConfiguration $config)
|
||||
{
|
||||
$this->viewHandler = $viewHandler;
|
||||
@@ -113,7 +113,7 @@ final class UserController extends BaseApiController
|
||||
|
||||
$data = $this->repository->getUsersForQuery($query);
|
||||
$view = new View($data, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Collection', 'User']);
|
||||
$view->getContext()->setGroups(self::GROUPS_COLLECTION);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -150,7 +150,7 @@ final class UserController extends BaseApiController
|
||||
}
|
||||
|
||||
$view = new View($user, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'User', 'User_Entity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ final class UserController extends BaseApiController
|
||||
public function meAction(): Response
|
||||
{
|
||||
$view = new View($this->getUser(), 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'User', 'User_Entity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -223,13 +223,13 @@ final class UserController extends BaseApiController
|
||||
$this->repository->saveUser($user);
|
||||
|
||||
$view = new View($user, 200);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'User', 'User_Entity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
|
||||
$view = new View($form);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'User', 'User_Entity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_FORM);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -285,7 +285,7 @@ final class UserController extends BaseApiController
|
||||
|
||||
if (false === $form->isValid()) {
|
||||
$view = new View($form, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'User', 'User_Entity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_FORM);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
@@ -293,7 +293,7 @@ final class UserController extends BaseApiController
|
||||
$this->repository->saveUser($user);
|
||||
|
||||
$view = new View($user, Response::HTTP_OK);
|
||||
$view->getContext()->setGroups(['Default', 'Entity', 'User', 'User_Entity']);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
return $this->viewHandler->handle($view);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user