update to Symfony 4.4 (#1275)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class SearchTermType extends AbstractType
|
||||
'label' => 'search',
|
||||
'required' => false,
|
||||
'constraints' => [
|
||||
new Length(['min' => 3])
|
||||
new Length(['min' => 3, 'allowEmptyString' => true])
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -143,7 +143,7 @@ class TimesheetRepository extends EntityRepository
|
||||
|
||||
$entityManager = $this->getEntityManager();
|
||||
$entityManager->persist($entry);
|
||||
$entityManager->flush($entry);
|
||||
$entityManager->flush();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user