-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace the admin shared training date list with a custom control/com…
…ponent From 94 level 4 errors to 66 with just this change. This is probably how efabrica-team/phpstan-latte#391 should be solved, components suggested in #143 (comment) Docs https://doc.nette.org/cs/application/components https://doc.nette.org/en/application/creating-links#toc-links-in-component for {plink} The UiControl class is there mostly, I mean only to suppress PhpStorm's "Member has private visibility but can be accessed via '__get' magic method" which is thrown in child classes of Nette\Application\UI\Control even though it has the same `@property-read` tag.
- Loading branch information
Showing
13 changed files
with
152 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace MichalSpacekCz\Application; | ||
|
||
use Nette\Application\UI\Control; | ||
use Nette\Bridges\ApplicationLatte\DefaultTemplate; | ||
|
||
/** | ||
* @property-read DefaultTemplate $template To suppress PhpStorm's "Member has private visibility but can be accessed via '__get' magic method" in child classes | ||
*/ | ||
abstract class UiControl extends Control | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace MichalSpacekCz\Training\DateList; | ||
|
||
enum DateListOrder | ||
{ | ||
|
||
case Asc; | ||
case Desc; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace MichalSpacekCz\Training\DateList; | ||
|
||
use DateTimeImmutable; | ||
use MichalSpacekCz\Application\UiControl; | ||
use MichalSpacekCz\Training\Dates\TrainingDate; | ||
use MichalSpacekCz\Training\Dates\UpcomingTrainingDates; | ||
|
||
class TrainingApplicationsList extends UiControl | ||
{ | ||
|
||
/** | ||
* @param list<TrainingDate> $dates | ||
*/ | ||
public function __construct( | ||
private readonly UpcomingTrainingDates $upcomingTrainingDates, | ||
private readonly array $dates, | ||
private readonly DateListOrder $order, | ||
private readonly bool $pastOnly, | ||
) { | ||
} | ||
|
||
|
||
public function render(): void | ||
{ | ||
$this->template->trainings = $this->dates; | ||
$this->template->now = $this->pastOnly ? null : new DateTimeImmutable(); | ||
$this->template->upcomingIds = $this->pastOnly ? [] : $this->upcomingTrainingDates->getPublicUpcomingIds(); | ||
$this->template->order = $this->order; | ||
$this->template->render(__DIR__ . '/trainingApplicationsList.latte'); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
site/app/Training/DateList/TrainingApplicationsListFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace MichalSpacekCz\Training\DateList; | ||
|
||
use MichalSpacekCz\Training\Dates\TrainingDate; | ||
|
||
interface TrainingApplicationsListFactory | ||
{ | ||
|
||
/** | ||
* @param list<TrainingDate> $dates | ||
*/ | ||
public function create(array $dates, DateListOrder $order, bool $pastOnly = false): TrainingApplicationsList; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters