Skip to content

Commit

Permalink
updated php-di to v7 by changing annotations to attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lung committed Sep 9, 2023
1 parent 14f314c commit 32c9fce
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 99 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"middlewares/negotiation": "^2.0",
"middlewares/trailing-slash": "^2.0",
"monolog/monolog": "^1.25",
"php-di/php-di": "^6.0",
"php-di/slim-bridge": "^3",
"phpmailer/phpmailer": "^6.0",
"robmorgan/phinx": "^0.12.5",
Expand Down
119 changes: 39 additions & 80 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 7 additions & 16 deletions src/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace kissj;

use DI\Annotation\Inject;
use DI\Attribute\Inject;
use kissj\Event\Event;
use kissj\FileHandler\FileHandler;
use kissj\FlashMessages\FlashMessagesBySession;
Expand All @@ -15,32 +15,23 @@
use Slim\Routing\RouteContext;
use Slim\Views\Twig;
use Symfony\Contracts\Translation\TranslatorInterface;
use Psr\Log\LoggerInterface;

abstract class AbstractController
{
/**
* @Inject()
*/
#[Inject]
protected FlashMessagesBySession $flashMessages;

/**
* @Inject("Psr\Log\LoggerInterface")
*/
#[Inject(LoggerInterface::class)]
protected Logger $logger;

/**
* @Inject()
*/
#[Inject]
protected Twig $view;

/**
* @Inject()
*/
#[Inject]
protected TranslatorInterface $translator;

/**
* @Inject()
*/
#[Inject]
protected FileHandler $fileHandler;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Application/ApplicationGetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function getApp(
$envPath,
$envFilename,
));
$containerBuilder->useAnnotations(true); // used in AbstractController
$containerBuilder->useAttributes(true); // used in AbstractController
if ($_ENV['DEBUG'] === 'false') {
// TODO add autowired definitions into container to get more performace
// https://php-di.org/doc/performances.html#optimizing-for-compilation
Expand Down
2 changes: 1 addition & 1 deletion src/User/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function getDashboard(User $user, Request $request, Response $response):
UserRole::ContingentAdminPl,
UserRole::ContingentAdminHu,
UserRole::ContingentAdminEu,
UserRole::ContingentAdminRo,
UserRole::ContingentAdminRo
=> $this->redirect($request, $response, 'admin-dashboard', $routerEventSlug),
};
}
Expand Down

0 comments on commit 32c9fce

Please sign in to comment.