Skip to content

Commit

Permalink
Added ContainerInterface type-hint to anonymous functions in the depe…
Browse files Browse the repository at this point in the history
…ndencies file
  • Loading branch information
rotimi committed May 25, 2024
1 parent 71eb414 commit 01344f2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions config/dependencies-dist.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
use \SlimMvcTools\ContainerKeys,
\SlimMvcTools\Controllers\BaseController;
\SlimMvcTools\Controllers\BaseController,
\Psr\Container\ContainerInterface;

////////////////////////////////////////////////////////////////////////////////
// Configure all the dependencies you'll need in your application in this file.
Expand All @@ -17,7 +18,7 @@
// See https://learn.microsoft.com/en-us/cpp/c-runtime-library/language-strings?view=msvc-170
$container[ContainerKeys::DEFAULT_LOCALE] = 'en_US';
$container[ContainerKeys::VALID_LOCALES] = ['en_US', 'fr_CA']; // add more values for languages you will be supporting in your application
$container[ContainerKeys::LOCALE_OBJ] = function ($c) { // An object managing localized strings
$container[ContainerKeys::LOCALE_OBJ] = function (ContainerInterface $c) { // An object managing localized strings

// See https://packagist.org/packages/vespula/locale
$ds = DIRECTORY_SEPARATOR;
Expand All @@ -37,7 +38,7 @@
};

// A PSR 3 / PSR Log Compliant logger
$container[ContainerKeys::LOGGER] = function ($c) {
$container[ContainerKeys::LOGGER] = function (ContainerInterface $c) {

// See https://packagist.org/packages/vespula/log
$ds = DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -66,7 +67,7 @@
];

// Object for rendering layout files
$container[ContainerKeys::LAYOUT_RENDERER] = $container->factory(function ($c) {
$container[ContainerKeys::LAYOUT_RENDERER] = $container->factory(function (ContainerInterface $c) {

// See https://github.com/rotexsoft/file-renderer
// Return a new instance on each access to
Expand All @@ -80,7 +81,7 @@
});

// Object for rendering view files
$container[ContainerKeys::VIEW_RENDERER] = $container->factory(function ($c) {
$container[ContainerKeys::VIEW_RENDERER] = $container->factory(function (ContainerInterface $c) {

// See https://github.com/rotexsoft/file-renderer
// Return a new instance on each access to
Expand All @@ -101,7 +102,7 @@
//
// \SlimMvcTools\Controllers\BaseController->actionLogin will work out of
// the box with any properly configured \Vespula\Auth\Adapter\* instance.
$container[ContainerKeys::VESPULA_AUTH] = function ($c) {
$container[ContainerKeys::VESPULA_AUTH] = function (ContainerInterface $c) {

// See https://packagist.org/packages/vespula/auth
$pdo = new \PDO(
Expand Down Expand Up @@ -146,14 +147,14 @@
////////////////////////////////////////////////////////////////////////////

// New PSR 7 Request Object
$container[ContainerKeys::NEW_REQUEST_OBJECT] = $container->factory(function ($c) {
$container[ContainerKeys::NEW_REQUEST_OBJECT] = $container->factory(function (ContainerInterface $c) {

$serverRequestCreator = \Slim\Factory\ServerRequestCreatorFactory::create();
return $serverRequestCreator->createServerRequestFromGlobals();
});

// New PSR 7 Response Object
$container[ContainerKeys::NEW_RESPONSE_OBJECT] = $container->factory(function ($c) {
$container[ContainerKeys::NEW_RESPONSE_OBJECT] = $container->factory(function (ContainerInterface $c) {

$responseFactory = \Slim\Factory\AppFactory::determineResponseFactory();
return $responseFactory->createResponse();
Expand Down

0 comments on commit 01344f2

Please sign in to comment.