Skip to content

Commit

Permalink
replace deprecated class
Browse files Browse the repository at this point in the history
  • Loading branch information
sinacek committed Nov 19, 2023
1 parent 4c9c372 commit f42048c
Show file tree
Hide file tree
Showing 93 changed files with 504 additions and 504 deletions.
4 changes: 2 additions & 2 deletions app/AccountancyModule/AccountancyHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\AccountancyModule;

use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;
use DateTimeInterface;
use InvalidArgumentException;
use Model\Common\ShouldNotHappen;
Expand Down Expand Up @@ -384,7 +384,7 @@ public static function groupState(string $s): string
}

/**
* @param Date[]|null[] $dates
* @param ChronosDate[]|null[] $dates
*
* @filter
*/
Expand Down
4 changes: 2 additions & 2 deletions app/AccountancyModule/CampModule/Components/ExportDialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\AccountancyModule\Components\Dialog;
use App\AccountancyModule\ExcelResponse;
use App\Forms\BaseForm;
use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;
use Model\Common\Services\QueryBus;
use Model\DTO\Camp\CampListItem;
use Model\Event\ReadModel\Queries\Excel\ExportCamps;
Expand Down Expand Up @@ -61,7 +61,7 @@ private function formSucceeded(ArrayHash $values): void
{
$this->presenter->sendResponse(
new ExcelResponse(
sprintf('Souhrn-táborů-%s', Date::today()->format('Y_n_j')),
sprintf('Souhrn-táborů-%s', ChronosDate::today()->format('Y_n_j')),
$this->queryBus->handle(new ExportCamps($values->campIds)),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\AccountancyModule\CampModule\Factories\IExportDialogFactory;
use App\AccountancyModule\Components\DataGrid;
use App\AccountancyModule\Factories\GridFactory;
use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;
use Model\Event\ReadModel\Queries\CampStates;

use function array_merge;
Expand Down Expand Up @@ -50,7 +50,7 @@ protected function createComponentGrid(): DataGrid

$grid->addYearFilter('year', 'Rok')
->setCondition(function (CampListDataSource $dataSource, $year): void {
$dataSource->filterByYear($year === DataGrid::OPTION_ALL ? null : (int) ($year ?? Date::today()->year));
$dataSource->filterByYear($year === DataGrid::OPTION_ALL ? null : (int) ($year ?? ChronosDate::today()->year));
});

$states = array_merge([DataGrid::OPTION_ALL => 'Nezrušené'], $this->queryBus->handle(new CampStates()));
Expand All @@ -67,7 +67,7 @@ protected function createComponentGrid(): DataGrid

$grid->setDefaultFilter([
'search' => '',
'year' => (string) Date::today()->year,
'year' => (string) ChronosDate::today()->year,
'state' => self::DEFAULT_STATE,
]);

Expand Down
12 changes: 6 additions & 6 deletions app/AccountancyModule/Components/FormControls/DateControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\AccountancyModule\Components\FormControls;

use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;
use InvalidArgumentException;
use Nette\Forms\Controls\BaseControl;
use Nette\Utils\Html;
Expand All @@ -21,8 +21,8 @@ class DateControl extends BaseControl

public function setDefaultValue(mixed $value): self
{
if (! $value instanceof Date && $value !== null) {
throw new InvalidArgumentException(sprintf('$value must be instance of %s or NULL', Date::class));
if (! $value instanceof ChronosDate && $value !== null) {
throw new InvalidArgumentException(sprintf('$value must be instance of %s or NULL', ChronosDate::class));
}

parent::setDefaultValue($value);
Expand All @@ -47,19 +47,19 @@ function (self $control): bool {
return $this;
}

public function getValue(): Date|null
public function getValue(): ChronosDate|null
{
$value = parent::getValue();

if ($value === null || $value === '') {
return null;
}

if ($value instanceof Date) {
if ($value instanceof ChronosDate) {
return $value;
}

return Date::createFromFormat(self::DATE_FORMAT, str_replace(' ', '', $value));
return ChronosDate::createFromFormat(self::DATE_FORMAT, str_replace(' ', '', $value));
}

public function getControl(): Html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\AccountancyModule\Components\DataGrid;
use App\AccountancyModule\EventModule\EducationListDataSource;
use App\AccountancyModule\Factories\GridFactory;
use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;

class DefaultPresenter extends BasePresenter
{
Expand All @@ -34,7 +34,7 @@ protected function createComponentGrid(): DataGrid

$grid->addYearFilter('year', 'Rok')
->setCondition(function (EducationListDataSource $dataSource, $year): void {
$dataSource->filterByYear($year === DataGrid::OPTION_ALL ? null : (int) ($year ?? Date::today()->year));
$dataSource->filterByYear($year === DataGrid::OPTION_ALL ? null : (int) ($year ?? ChronosDate::today()->year));
});

$grid->addFilterText('search', 'Název', 'name')
Expand All @@ -47,7 +47,7 @@ protected function createComponentGrid(): DataGrid
$grid->setDefaultSort(['name' => 'ASC']);

$grid->setDefaultFilter([
'year' => (string) Date::today()->year,
'year' => (string) ChronosDate::today()->year,
]);

return $grid;
Expand Down
4 changes: 2 additions & 2 deletions app/AccountancyModule/EventModule/components/ExportDialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\AccountancyModule\Components\Dialog;
use App\AccountancyModule\ExcelResponse;
use App\Forms\BaseForm;
use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;
use Model\Common\Services\QueryBus;
use Model\DTO\Event\EventListItem;
use Model\Event\ReadModel\Queries\Excel\ExportEvents;
Expand Down Expand Up @@ -61,7 +61,7 @@ private function formSucceeded(ArrayHash $values): void
{
$this->presenter->sendResponse(
new ExcelResponse(
sprintf('Souhrn-akci-%s', Date::today()->format('Y_n_j')),
sprintf('Souhrn-akci-%s', ChronosDate::today()->format('Y_n_j')),
$this->queryBus->handle(new ExportEvents($values->eventIds)),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\AccountancyModule\EventModule\Components\ExportDialog;
use App\AccountancyModule\EventModule\Factories\IExportDialogFactory;
use App\AccountancyModule\Factories\GridFactory;
use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;
use Model\Auth\Resources\Event as EventResource;
use Model\DTO\Event\EventListItem;
use Model\Event\Commands\CancelEvent;
Expand Down Expand Up @@ -85,7 +85,7 @@ protected function createComponentGrid(): DataGrid

$grid->addYearFilter('year', 'Rok')
->setCondition(function (EventListDataSource $dataSource, $year): void {
$dataSource->filterByYear($year === DataGrid::OPTION_ALL ? null : (int) ($year ?? Date::today()->year));
$dataSource->filterByYear($year === DataGrid::OPTION_ALL ? null : (int) ($year ?? ChronosDate::today()->year));
});

$states = array_merge([DataGrid::OPTION_ALL => 'Nezrušené'], $this->queryBus->handle(new EventStates()));
Expand All @@ -102,7 +102,7 @@ protected function createComponentGrid(): DataGrid

$grid->setDefaultFilter([
'search' => '',
'year' => (string) Date::today()->year,
'year' => (string) ChronosDate::today()->year,
'state' => self::DEFAULT_STATE,
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\AccountancyModule\EventModule\Factories\IFunctionsControlFactory;
use App\Forms\BaseForm;
use App\MyValidators;
use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;
use Model\Auth\Resources\Event;
use Model\Cashbook\Cashbook\CashbookId;
use Model\Cashbook\Cashbook\PaymentMethod;
Expand Down Expand Up @@ -58,7 +58,7 @@ public function renderDefault(int|null $aid): void

$accessEditBase = $this->authorizator->isAllowed(Event::UPDATE, $aid);
$this->template->setParameters([
'highlightCloseButton' => $this->event->getEndDate()->diffInDays(Date::now(), false) > 14,
'highlightCloseButton' => $this->event->getEndDate()->diffInDays(ChronosDate::now(), false) > 14,
]);

if ($accessEditBase) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\AccountancyModule\PaymentModule\BasePresenter;
use App\AccountancyModule\PaymentModule\Components\GroupForm;
use App\AccountancyModule\PaymentModule\Factories\IGroupFormFactory;
use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;
use Model\Event\Camp;
use Model\Payment\Group\SkautisEntity;
use Model\Payment\ReadModel\Queries\CampsWithoutGroupQuery;
Expand All @@ -23,7 +23,7 @@ public function __construct(private IGroupFormFactory $formFactory)

public function actionDefault(int $campId): void
{
$camps = $this->queryBus->handle(new CampsWithoutGroupQuery(Date::today()->year));
$camps = $this->queryBus->handle(new CampsWithoutGroupQuery(ChronosDate::today()->year));

if (! $this->isEditable || ! isset($camps[$campId])) {
$this->flashMessage('Pro tento tábor není možné vytvořit skupinu plateb', 'danger');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace App\AccountancyModule\PaymentModule\CampModule;

use App\AccountancyModule\PaymentModule\BasePresenter;
use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;
use Model\Payment\ReadModel\Queries\CampsWithoutGroupQuery;

use function array_values;
Expand All @@ -15,7 +15,7 @@ final class SelectForGroupPresenter extends BasePresenter
public function renderDefault(): void
{
$this->template->setParameters(
['camps' => array_values($this->queryBus->handle(new CampsWithoutGroupQuery(Date::today()->year)))],
['camps' => array_values($this->queryBus->handle(new CampsWithoutGroupQuery(ChronosDate::today()->year)))],
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\AccountancyModule\PaymentModule\Components\GroupForm;
use App\AccountancyModule\PaymentModule\Factories\IGroupFormFactory;
use Assert\Assertion;
use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;
use Model\Event\Education;
use Model\Payment\Group\SkautisEntity;
use Model\Payment\ReadModel\Queries\EducationsWithoutGroupQuery;
Expand All @@ -26,7 +26,7 @@ public function __construct(private IGroupFormFactory $formFactory)

public function actionDefault(int $educationId): void
{
$educations = $this->queryBus->handle(new EducationsWithoutGroupQuery(Date::today()->year));
$educations = $this->queryBus->handle(new EducationsWithoutGroupQuery(ChronosDate::today()->year));

if (! $this->isEditable || ! array_key_exists($educationId, $educations)) {
$this->flashMessage('Pro tuto vzdělávací akci není možné vytvořit skupinu plateb', 'danger');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
namespace App\AccountancyModule\PaymentModule\EducationModule;

use App\AccountancyModule\PaymentModule\BasePresenter;
use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;
use Model\Payment\ReadModel\Queries\EducationsWithoutGroupQuery;

class SelectForGroupPresenter extends BasePresenter
{
public function actionDefault(): void
{
$this->template->setParameters(['educations' => $this->queryBus->handle(new EducationsWithoutGroupQuery(Date::today()->year))]);
$this->template->setParameters(['educations' => $this->queryBus->handle(new EducationsWithoutGroupQuery(ChronosDate::today()->year))]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\AccountancyModule\PaymentModule\BasePresenter;
use App\AccountancyModule\PaymentModule\Components\GroupForm;
use App\AccountancyModule\PaymentModule\Factories\IGroupFormFactory;
use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;
use Model\Event\Event;
use Model\Payment\Group\SkautisEntity;
use Model\Payment\ReadModel\Queries\EventsWithoutGroupQuery;
Expand All @@ -23,7 +23,7 @@ public function __construct(private IGroupFormFactory $formFactory)

public function actionDefault(int $eventId): void
{
$eventsWithoutGroup = $this->queryBus->handle(new EventsWithoutGroupQuery(Date::today()->year));
$eventsWithoutGroup = $this->queryBus->handle(new EventsWithoutGroupQuery(ChronosDate::today()->year));

if (! $this->isEditable || ! isset($eventsWithoutGroup[$eventId])) {
$this->flashMessage('Pro tuto akci není možné vytvořit skupinu plateb', 'danger');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace App\AccountancyModule\PaymentModule\EventModule;

use App\AccountancyModule\PaymentModule\BasePresenter;
use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;
use Model\Payment\ReadModel\Queries\EventsWithoutGroupQuery;

use function array_values;
Expand All @@ -15,7 +15,7 @@ final class SelectForGroupPresenter extends BasePresenter
public function renderDefault(): void
{
$this->template->setParameters(
['events' => array_values($this->queryBus->handle(new EventsWithoutGroupQuery(Date::today()->year)))],
['events' => array_values($this->queryBus->handle(new EventsWithoutGroupQuery(ChronosDate::today()->year)))],
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use App\AccountancyModule\PaymentModule\Factories;
use App\AccountancyModule\PaymentModule\Factories\IGroupFormFactory;
use Assert\Assertion;
use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;
use Model\Common\Registration;
use Model\Common\UnitId;
use Model\Payment\Group\SkautisEntity;
Expand Down Expand Up @@ -57,7 +57,7 @@ protected function createComponentForm(): GroupForm
);

$form->fillName('Registrace ' . $registration->getYear());
$form->fillDueDate(Date::createFromDate($registration->getYear(), 1, 15));
$form->fillDueDate(ChronosDate::createFromDate($registration->getYear(), 1, 15));

return $form;
}
Expand Down
4 changes: 2 additions & 2 deletions app/AccountancyModule/PaymentModule/components/GroupForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\AccountancyModule\Components\FormControls\DateControl;
use App\Forms\BaseForm;
use Assert\Assertion;
use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;
use DateTimeImmutable;
use Model\Common\Services\QueryBus;
use Model\Common\UnitId;
Expand Down Expand Up @@ -63,7 +63,7 @@ public function fillName(string $name): void
$nameControl->setDefaultValue($name);
}

public function fillDueDate(Date $dueDate): void
public function fillDueDate(ChronosDate $dueDate): void
{
if ($dueDate->isSaturday()) {
$dueDate = $dueDate->addDays(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\AccountancyModule\Components\BaseControl;
use App\Forms\BaseContainer;
use App\Forms\BaseForm;
use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;
use Model\Common\EmailAddress;
use Model\Common\Services\CommandBus;
use Model\Payment\Commands\Payment\CreatePayment;
Expand Down Expand Up @@ -72,7 +72,7 @@ protected function createComponentForm(): BaseForm
}

/** @param string[] $emails */
public function addPerson(int $id, array $emails, string $name, float|null $amount = null, string $note = '', string $variableSymbol = '', Date|null $dueDate = null): void
public function addPerson(int $id, array $emails, string $name, float|null $amount = null, string $note = '', string $variableSymbol = '', ChronosDate|null $dueDate = null): void
{
$form = $this['form'];
$persons = $form['persons'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace App\AccountancyModule\PaymentModule;

use App\Forms\BaseForm;
use Cake\Chronos\Date;
use Cake\Chronos\ChronosDate;
use Model\DTO\Payment\Group;
use Model\DTO\Payment\RepaymentCandidate;
use Model\Payment\BankAccount\AccountNumber;
Expand Down Expand Up @@ -50,7 +50,7 @@ protected function createComponentForm(): BaseForm
$form->addDate('date', 'Datum splatnosti:')
->disableWeekends()
->setRequired(true)
->setDefaultValue(Date::now()->addWeekday());
->setDefaultValue(ChronosDate::now()->addWeekday());

$form->addSubmit('send', 'Založit příkazy k úhradě')
->setHtmlAttribute('class', 'btn btn-primary btn-large');
Expand Down Expand Up @@ -142,7 +142,7 @@ private function repaymentFormSubmitted(BaseForm $form): void
$this->commandBus->handle(
new CreateRepayments(
$bankAccount->getNumber(),
$values->date ?? Date::now(),
$values->date ?? ChronosDate::now(),
$repayments,
$bankAccount->getToken(),
),
Expand Down
Loading

0 comments on commit f42048c

Please sign in to comment.