Comments (5)
If a 35'th PR will be accepted the answer to my question will follow this:
use Igni\Application\Http\MiddlewareAggregator;
use Igni\Application\Providers\MiddlewareProvider;
use Igni\Application\Providers\ServiceProvider;
use Microparts\Configuration\Configuration;
use Microparts\I18n\I18nInterface;
use Microparts\I18n\Manager;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ServerRequestInterface;
class I18nModule implements MiddlewareProvider
{
/**
* @param \Igni\Application\Http\MiddlewareAggregator $aggregate
*/
public function provideMiddleware(MiddlewareAggregator $aggregate): void
{
/** @var \Igni\Container\ServiceLocator $container */
$container = $aggregate->getContainer();
$aggregate->use(function (ServerRequestInterface $request, callable $next) use ($container) {
$container->share(I18nInterface::class, function (ContainerInterface $container) use ($request) {
$manager = new Manager($container->get(Configuration::class));
return $manager->withMessage($request)->load();
});
return $next($request);
});
}
}
I don't think that this a pretty solution, because the method does not, contains the second argument with the application container... but it works.
from framework.
My task is a register following service to the Igni ServiceLocator
. This service depends on other class which registered in ServiceLocator
and depends on SwooleHttpRequest
(wrapped in the Igni ServerRequest
).
Following method won't work because globals vars not filled when Swoole the starts own server:
https://github.com/microparts/igni-support-php/blob/master/src/Modules/I18nModule.php#L27
For the better understanding similar cases )
from framework.
I found some bugs, good time to create a PR
from framework.
First igniphp/network#6
from framework.
Second #35 :)
from framework.
Related Issues (20)
- Router use private properties which disable any route listing HOT 2
- Howto integrate `symfony/dependency-injection` instead of internal DI HOT 2
- Remove pretty format on Json response HOT 1
- Add Gzip support on response HOT 4
- Howto to use mysql queries (coroutine) in controller HOT 1
- Create custom ErrorMiddleware to support Rest HOT 2
- Replace http server logger with PSR logger. HOT 1
- Simplify application bootstrapping by configuration files. HOT 1
- Allow creating config from ini, json or yml files.
- Extract server into separate repository `http-server` HOT 1
- Last router method with same name is overwrite previous with other http method HOT 5
- In tests not possible to pass attributes by example HOT 4
- How I can register my additional services in the service provider? HOT 5
- In the middleware request attributes does not parsed and filled to the object HOT 1
- How to call registered Module for each request? HOT 2
- Can i disable log HOT 1
- PHP 7.3 support HOT 4
- Workerman support HOT 1
- Unit testing? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from framework.