asdf
This commit is contained in:
parent
3760a9d43a
commit
f054af35c3
107 changed files with 8372 additions and 186 deletions
10
app/src/Factory/ContainerProvider.php
Normal file
10
app/src/Factory/ContainerProvider.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Lubian\NoFramework\Factory;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
interface ContainerProvider
|
||||
{
|
||||
public function getContainer(): ContainerInterface;
|
||||
}
|
28
app/src/Factory/DiactorosRequestFactory.php
Normal file
28
app/src/Factory/DiactorosRequestFactory.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Lubian\NoFramework\Factory;
|
||||
|
||||
use Laminas\Diactoros\ServerRequestFactory;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
final class DiactorosRequestFactory implements RequestFactory
|
||||
{
|
||||
public function __construct(private readonly ServerRequestFactory $factory)
|
||||
{
|
||||
}
|
||||
|
||||
public function fromGlobals(): ServerRequestInterface
|
||||
{
|
||||
return $this->factory::fromGlobals();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UriInterface|string $uri
|
||||
* @param array<mixed> $serverParams
|
||||
*/
|
||||
public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface
|
||||
{
|
||||
return $this->factory->createServerRequest($method, $uri, $serverParams);
|
||||
}
|
||||
}
|
22
app/src/Factory/FileSystemSettingsProvider.php
Normal file
22
app/src/Factory/FileSystemSettingsProvider.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Lubian\NoFramework\Factory;
|
||||
|
||||
use Lubian\NoFramework\Settings;
|
||||
|
||||
use function assert;
|
||||
|
||||
final class FileSystemSettingsProvider implements SettingsProvider
|
||||
{
|
||||
public function __construct(
|
||||
private string $filePath
|
||||
) {
|
||||
}
|
||||
|
||||
public function getSettings(): Settings
|
||||
{
|
||||
$settings = require $this->filePath;
|
||||
assert($settings instanceof Settings);
|
||||
return $settings;
|
||||
}
|
||||
}
|
25
app/src/Factory/PipelineProvider.php
Normal file
25
app/src/Factory/PipelineProvider.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Lubian\NoFramework\Factory;
|
||||
|
||||
use Lubian\NoFramework\Http\ContainerPipeline;
|
||||
use Lubian\NoFramework\Http\Pipeline;
|
||||
use Lubian\NoFramework\Http\RoutedRequestHandler;
|
||||
use Lubian\NoFramework\Settings;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class PipelineProvider
|
||||
{
|
||||
public function __construct(
|
||||
private Settings $settings,
|
||||
private RoutedRequestHandler $tip,
|
||||
private ContainerInterface $container,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getPipeline(): Pipeline
|
||||
{
|
||||
$middlewares = require $this->settings->middlewaresFile;
|
||||
return new ContainerPipeline($middlewares, $this->tip, $this->container);
|
||||
}
|
||||
}
|
11
app/src/Factory/RequestFactory.php
Normal file
11
app/src/Factory/RequestFactory.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Lubian\NoFramework\Factory;
|
||||
|
||||
use Psr\Http\Message\ServerRequestFactoryInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
interface RequestFactory extends ServerRequestFactoryInterface
|
||||
{
|
||||
public function fromGlobals(): ServerRequestInterface;
|
||||
}
|
25
app/src/Factory/SettingsContainerProvider.php
Normal file
25
app/src/Factory/SettingsContainerProvider.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Lubian\NoFramework\Factory;
|
||||
|
||||
use DI\ContainerBuilder;
|
||||
use Lubian\NoFramework\Settings;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
final class SettingsContainerProvider implements ContainerProvider
|
||||
{
|
||||
public function __construct(
|
||||
private SettingsProvider $settingsProvider,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getContainer(): ContainerInterface
|
||||
{
|
||||
$builder = new ContainerBuilder;
|
||||
$settings = $this->settingsProvider->getSettings();
|
||||
$dependencies = require $settings->dependenciesFile;
|
||||
$dependencies[Settings::class] = fn (): Settings => $settings;
|
||||
$builder->addDefinitions($dependencies);
|
||||
return $builder->build();
|
||||
}
|
||||
}
|
10
app/src/Factory/SettingsProvider.php
Normal file
10
app/src/Factory/SettingsProvider.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Lubian\NoFramework\Factory;
|
||||
|
||||
use Lubian\NoFramework\Settings;
|
||||
|
||||
interface SettingsProvider
|
||||
{
|
||||
public function getSettings(): Settings;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue