Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)

This commit is contained in:
Kevin Papst
2022-12-31 21:19:55 +01:00
committed by GitHub
parent 95e06746bd
commit 90a0fd8a22
2164 changed files with 83700 additions and 86426 deletions

View File

@@ -1,147 +0,0 @@
<?php
declare(strict_types=1);
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\API\Model;
use JMS\Serializer\Annotation as Serializer;
/**
* @Serializer\ExclusionPolicy("all")
*/
final class I18nConfig
{
/**
* Format used for toolbar queries
*
* @var string
*
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
* @Serializer\Type(name="string")
* @phpstan-ignore-next-line
*/
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")
* @phpstan-ignore-next-line
*/
private $dateTime = '';
/**
* Format used to display date values (see PHP function date_format)
*
* @var string
*
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
* @Serializer\Type(name="string")
* @phpstan-ignore-next-line
*/
private $date = '';
/**
* Format used to display times (see PHP function date_format)
*
* @var string
*
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
* @Serializer\Type(name="string")
* @phpstan-ignore-next-line
*/
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")
* @phpstan-ignore-next-line
*/
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")
* @phpstan-ignore-next-line
*/
private $is24hours = true;
/**
* The current time of the user
*
* @var \DateTime
*
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
* @Serializer\Type(name="DateTime")
* @phpstan-ignore-next-line
*/
private $now;
public function setNow(\DateTime $now): I18nConfig
{
$this->now = $now;
return $this;
}
public function setFormDate(string $formDate): I18nConfig
{
$this->formDate = $formDate;
return $this;
}
public function setDateTime(string $dateTime): I18nConfig
{
$this->dateTime = $dateTime;
return $this;
}
public function setDate(string $date): I18nConfig
{
$this->date = $date;
return $this;
}
public function setDuration(string $duration): I18nConfig
{
$this->duration = $duration;
return $this;
}
public function setTime(string $time): I18nConfig
{
$this->time = $time;
return $this;
}
public function setIs24hours(bool $is24hours): I18nConfig
{
$this->is24hours = $is24hours;
return $this;
}
}

View File

@@ -0,0 +1,73 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\API\Model;
use JMS\Serializer\Annotation as Serializer;
/**
* @internal
*/
#[Serializer\ExclusionPolicy('all')]
final class PageAction
{
/**
* ID of the action
*/
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Serializer\Type(name: 'string')]
public readonly string $id;
/**
* Translated title to show the user
*/
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Serializer\Type(name: 'string')]
public readonly string $title;
/**
* URL of the action
*/
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Serializer\Type(name: 'string')]
public readonly ?string $url;
/**
* HTML classes to be used
*/
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Serializer\Type(name: 'string')]
public readonly ?string $class;
/**
* HTML (data) attributes to render the action
*/
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Serializer\Type(name: 'array<string, string>')]
public readonly array $attr;
/**
* Whether to render a divider before this item
*/
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Serializer\Type(name: 'boolean')]
public readonly bool $divider;
public function __construct(string $title, array $settings = [])
{
$this->id = $title;
$this->title = $settings['title'] ?? $title;
$this->url = $settings['url'] ?? null;
$this->class = $settings['class'] ?? null;
$this->attr = $settings['attr'] ?? [];
$this->divider = ($title === 'trash' || (str_contains($title, 'divider') && ($this->url === null || $this->url === '')));
}
}

View File

@@ -1,7 +1,5 @@
<?php
declare(strict_types=1);
/*
* This file is part of the Kimai time-tracking app.
*
@@ -14,31 +12,23 @@ namespace App\API\Model;
use App\Plugin\Plugin as CorePlugin;
use JMS\Serializer\Annotation as Serializer;
/**
* @Serializer\ExclusionPolicy("all")
*/
class Plugin
#[Serializer\ExclusionPolicy('all')]
final class Plugin
{
/**
* The plugin name, eg. "ExpensesBundle"
*
* @var string
*
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
* @Serializer\Type(name="string")
*/
protected $name;
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Serializer\Type(name: 'string')]
private ?string $name = null;
/**
* The plugin version, eg. "1.14"
*
* @var string
*
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
* @Serializer\Type(name="string")
*/
protected $version;
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Serializer\Type(name: 'string')]
private ?string $version = null;
public function __construct(CorePlugin $plugin)
{

View File

@@ -1,7 +1,5 @@
<?php
declare(strict_types=1);
/*
* This file is part of the Kimai time-tracking app.
*
@@ -13,117 +11,67 @@ namespace App\API\Model;
use JMS\Serializer\Annotation as Serializer;
/**
* @Serializer\ExclusionPolicy("none")
*/
#[Serializer\ExclusionPolicy('none')]
final class TimesheetConfig
{
/**
* 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")
* @phpstan-ignore-next-line
*/
private $trackingMode = 'default';
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Serializer\Type(name: 'string')]
public string $trackingMode = 'default';
/**
* Default begin datetime in PHP format
*
* @var string
*
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
* @Serializer\Type(name="string")
* @phpstan-ignore-next-line
*/
private $defaultBeginTime = 'now';
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Serializer\Type(name: 'string')]
public string $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")
* @phpstan-ignore-next-line
*/
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")
* @phpstan-ignore-next-line
*/
private $activeEntriesSoftLimit = 1;
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Serializer\Type(name: 'integer')]
public int $activeEntriesHardLimit = 1;
/**
* Whether entries for future times are allowed
*
* @var bool
*
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
* @Serializer\Type(name="boolean")
* @phpstan-ignore-next-line
*/
private $isAllowFutureTimes = true;
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Serializer\Type(name: 'boolean')]
public bool $isAllowFutureTimes = true;
/**
* Whether overlapping entries are allowed
*
* @var bool
*
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
* @Serializer\Type(name="boolean")
* @phpstan-ignore-next-line
*/
private $isAllowOverlapping = true;
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Serializer\Type(name: 'boolean')]
public bool $isAllowOverlapping = true;
public function setTrackingMode(string $trackingMode): TimesheetConfig
public function setTrackingMode(string $trackingMode): void
{
$this->trackingMode = $trackingMode;
return $this;
}
public function setDefaultBeginTime(string $defaultBeginTime): TimesheetConfig
public function setDefaultBeginTime(string $defaultBeginTime): void
{
$this->defaultBeginTime = $defaultBeginTime;
return $this;
}
public function setActiveEntriesHardLimit(int $activeEntriesHardLimit): TimesheetConfig
public function setActiveEntriesHardLimit(int $activeEntriesHardLimit): void
{
$this->activeEntriesHardLimit = $activeEntriesHardLimit;
return $this;
}
public function setActiveEntriesSoftLimit(int $activeEntriesSoftLimit): TimesheetConfig
{
$this->activeEntriesSoftLimit = $activeEntriesSoftLimit;
return $this;
}
public function setIsAllowFutureTimes(bool $isAllowFutureTimes): TimesheetConfig
public function setIsAllowFutureTimes(bool $isAllowFutureTimes): void
{
$this->isAllowFutureTimes = $isAllowFutureTimes;
return $this;
}
public function setIsAllowOverlapping(bool $isAllowOverlapping): TimesheetConfig
public function setIsAllowOverlapping(bool $isAllowOverlapping): void
{
$this->isAllowOverlapping = $isAllowOverlapping;
return $this;
}
}

View File

@@ -1,7 +1,5 @@
<?php
declare(strict_types=1);
/*
* This file is part of the Kimai time-tracking app.
*
@@ -14,71 +12,37 @@ namespace App\API\Model;
use App\Constants;
use JMS\Serializer\Annotation as Serializer;
/**
* @Serializer\ExclusionPolicy("all")
*/
class Version
#[Serializer\ExclusionPolicy('all')]
final class Version
{
/**
* Kimai Version, eg. "1.14"
*
* @var string
*
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
* @Serializer\Type(name="string")
* Kimai Version, eg. "2.0.0"
*/
protected $version = Constants::VERSION;
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Serializer\Type(name: 'string')]
public readonly string $version;
/**
* Kimai Version as integer, eg. 11400
* Kimai Version as integer, eg. 20000
*
* Follows the same logic as PHP_VERSION_ID, see https://www.php.net/manual/de/function.phpversion.php
*
* @var int
*
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
* @Serializer\Type(name="integer")
*/
protected $versionId = Constants::VERSION_ID;
/**
* 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;
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Serializer\Type(name: 'integer')]
public readonly int $versionId;
/**
* A full copyright notice
*
* @var string
*
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
* @Serializer\Type(name="string")
*/
protected $copyright = Constants::SOFTWARE . ' ' . Constants::VERSION . ' by Kevin Papst and contributors.';
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Serializer\Type(name: 'string')]
public readonly string $copyright;
public function __construct()
{
$this->version = Constants::VERSION;
$this->versionId = Constants::VERSION_ID;
$this->copyright = Constants::SOFTWARE . ' ' . Constants::VERSION . ' by Kevin Papst.';
}
}