update to Symfony 4.4 (#1275)

This commit is contained in:
Kevin Papst
2020-02-04 15:29:26 +01:00
committed by GitHub
parent 375691365e
commit 75dcae6fbe
53 changed files with 1046 additions and 1019 deletions

View File

@@ -11,7 +11,6 @@ declare(strict_types=1);
namespace App\API;
use App\Entity\User;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
@@ -19,12 +18,4 @@ abstract class BaseApiController extends AbstractController
{
public const DATE_FORMAT = DateTimeType::HTML5_FORMAT;
public const DATE_FORMAT_PHP = 'Y-m-d\TH:m:s';
/**
* @return User|null
*/
protected function getUser()
{
return parent::getUser();
}
}

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace App\API;
use App\Entity\Customer;
use App\Entity\User;
use App\Event\CustomerMetaDefinitionEvent;
use App\Form\API\CustomerApiEditForm;
use App\Repository\CustomerRepository;
@@ -78,8 +79,11 @@ class CustomerController extends BaseApiController
*/
public function cgetAction(ParamFetcherInterface $paramFetcher): Response
{
/** @var User $user */
$user = $this->getUser();
$query = new CustomerQuery();
$query->setCurrentUser($this->getUser());
$query->setCurrentUser($user);
if (null !== ($order = $paramFetcher->get('order'))) {
$query->setOrder($order);

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace App\API;
use App\Entity\Project;
use App\Entity\User;
use App\Event\ProjectMetaDefinitionEvent;
use App\Form\API\ProjectApiEditForm;
use App\Repository\ProjectRepository;
@@ -89,8 +90,11 @@ class ProjectController extends BaseApiController
*/
public function cgetAction(ParamFetcherInterface $paramFetcher): Response
{
/** @var User $user */
$user = $this->getUser();
$query = new ProjectQuery();
$query->setCurrentUser($this->getUser());
$query->setCurrentUser($user);
if (null !== ($order = $paramFetcher->get('order'))) {
$query->setOrder($order);

View File

@@ -170,8 +170,11 @@ final class TeamController extends BaseApiController
*/
public function postAction(Request $request): Response
{
/** @var User $user */
$user = $this->getUser();
$team = new Team();
$team->setTeamLead($this->getUser());
$team->setTeamLead($user);
$form = $this->createForm(TeamApiEditForm::class, $team);

View File

@@ -302,7 +302,10 @@ class TimesheetController extends BaseApiController
*/
public function postAction(Request $request): Response
{
$timesheet = $this->service->createNewTimesheet($this->getUser(), $request);
/** @var User $user */
$user = $this->getUser();
$timesheet = $this->service->createNewTimesheet($user, $request);
$mode = $this->getTrackingMode();
@@ -520,7 +523,10 @@ class TimesheetController extends BaseApiController
*/
public function activeAction(): Response
{
$data = $this->repository->getActiveEntries($this->getUser());
/** @var User $user */
$user = $this->getUser();
$data = $this->repository->getActiveEntries($user);
$view = new View($data, 200);
$view->getContext()->setGroups(['Default', 'Subresource', 'Timesheet']);
@@ -600,7 +606,10 @@ class TimesheetController extends BaseApiController
throw new AccessDeniedHttpException('You are not allowed to re-start this timesheet');
}
$copyTimesheet = $this->service->createNewTimesheet($this->getUser());
/** @var User $user */
$user = $this->getUser();
$copyTimesheet = $this->service->createNewTimesheet($user);
$copyTimesheet
->setBegin($this->dateTime->createDateTime())

View File

@@ -112,6 +112,7 @@ final class InvoiceController extends AbstractController
}
return $this->render('invoice/index.html.twig', [
'query' => $query,
'model' => $model,
'form' => $form->createView(),
'preview' => $showPreview,

View File

@@ -36,7 +36,9 @@ class Role
* @var string
*
* @ORM\Column(name="name", type="string", length=50, nullable=false)
* @Assert\Length(min=5, max=50)
* @Assert\NotNull()
* @Assert\NotBlank()
* @Assert\Length(allowEmptyString=false, min=5, max=50)
*/
private $name;

View File

@@ -36,7 +36,7 @@ class SearchTermType extends AbstractType
'label' => 'search',
'required' => false,
'constraints' => [
new Length(['min' => 3])
new Length(['min' => 3, 'allowEmptyString' => true])
],
]);
}

View File

@@ -9,6 +9,7 @@
namespace App\Invoice\Calculator;
use App\Invoice\CalculatorInterface;
use App\Invoice\InvoiceItem;
use App\Invoice\InvoiceModel;
@@ -87,11 +88,17 @@ abstract class AbstractCalculator
}
/**
* @deprecated since 1.8 will be removed with 2.0
* @return string
*/
public function getCurrency(): string
{
return $this->model->getCustomer()->getCurrency();
@trigger_error(
sprintf('%s::getCurrency() is deprecated and will be removed with 2.0', CalculatorInterface::class),
E_USER_DEPRECATED
);
return $this->model->getCurrency();
}
/**

View File

@@ -52,6 +52,7 @@ interface CalculatorInterface
/**
* Returns the currency for the invoices amounts.
*
* @deprecated since 1.8 will be removed with 2.0
* @return string
*/
public function getCurrency(): string;

View File

@@ -211,13 +211,23 @@ final class InvoiceModel
return $this->formatter;
}
public function getCurrency(): string
{
if (null === $this->getCustomer()) {
// this should be set from the configuration
return Customer::DEFAULT_CURRENCY;
}
return $this->getCustomer()->getCurrency();
}
public function toArray(): array
{
$model = $this;
$customer = $model->getCustomer();
$project = $model->getQuery()->getProject();
$activity = $model->getQuery()->getActivity();
$currency = $model->getCalculator()->getCurrency();
$currency = $this->getCurrency();
$tax = $model->getCalculator()->getTax();
$total = $model->getCalculator()->getTotal();
$subtotal = $model->getCalculator()->getSubtotal();

View File

@@ -143,7 +143,7 @@ class TimesheetRepository extends EntityRepository
$entityManager = $this->getEntityManager();
$entityManager->persist($entry);
$entityManager->flush($entry);
$entityManager->flush();
return true;
}