Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Routing/SettlementsPreloadMiddlewareBootstrap.php
  • Loading branch information
Sergey Surkov committed Sep 15, 2021
2 parents 4c48e12 + 11377c8 commit c1bf88e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "symbiotic/full",
"description": "Полная сборка пакетов фреймворка Symbiotic.",
"license": "BSD-3-Clause",
"version": "1.2.0",
"version": "1.2.12",
"authors": [{
"name": "Surkov Sergey",
"role": "creator"
Expand Down
4 changes: 3 additions & 1 deletion src/Http/Kernel/HttpRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public function run(): bool
$handler = $app['events']->dispatch(
new PreloadKernelHandler($app->make(HttpKernelInterface::class))
);
// ставим в начало проверку префикса
$handler->prepend(new RequestPrefixMiddleware($app('config::uri_prefix', null), $app[ResponseFactoryInterface::class]));
// ставим в конец загрузку провайдеров Http Ядра.
$handler->append(
new MiddlewareCallback(function (ServerRequestInterface $request, RequestHandlerInterface $handler)use($app): ResponseInterface {
$app->runBefore();
Expand Down Expand Up @@ -137,7 +139,7 @@ public function sendResponse(ResponseInterface $response)
$sender = new ResponseSender($response);
$sender->render();
if (\function_exists('fastcgi_finish_request')) {
\fastcgi_finish_request();
\register_shutdown_function(function(){\fastcgi_finish_request();});
} elseif (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
static::closeOutputBuffers(0, true);
}
Expand Down
15 changes: 13 additions & 2 deletions src/Http/Kernel/RoutingHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Symbiotic\Http\Middleware\ {MiddlewaresCollection, MiddlewaresDispatcher};
use Psr\Http\Message\ {ResponseInterface, ServerRequestInterface};
use Psr\Http\Server\RequestHandlerInterface;
use Symbiotic\Apps\AppsRepositoryInterface;
use Symbiotic\Core\CoreInterface;


Expand All @@ -32,7 +33,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
/**
* Для того чтобы не грузить все сервисы ядра,
* сначала мы определяем роут если роута нет, нет смысла грузить ядро
* Посредник дублирует поведение данного обработчика, но только пр роутинге поселений
* Посредник дублирует поведение данного обработчика, но только при роутинге поселений
* @see \Symbiotic\Routing\KernelPreloadFindRouteMiddleware::process()
*/
$route = $app['route'];
Expand All @@ -41,9 +42,19 @@ public function handle(ServerRequestInterface $request): ResponseInterface
$route = $app['router']->match($request->getMethod(), $path);
}
if ($route) {
/**
* @todo наверно надо перенести отработку в {@see RouteHandler::handle()} после бута самого приложения
*/
$middlewares = $route->getMiddlewares();
if (!empty($middlewares)) {
$app[MiddlewaresDispatcher::class]->factoryCollection($middlewares);
$action = $route->getAction();
if(isset($action['app'])) {
$app[AppsRepositoryInterface::class]->getBootedApp($action['app']);
}

$middlewares = $app[MiddlewaresDispatcher::class]->factoryCollection($middlewares);
} else {
$middlewares = [];
}
return (new MiddlewaresCollection($middlewares))->process($request, new RouteHandler($app, $route));
} else {
Expand Down
4 changes: 0 additions & 4 deletions src/Packages/PackagesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ public function get($key): array
*/
public function getPackages(): array
{
$time = microtime();
if (is_null($this->items)) {
$this->items = ($this->cache && ($data = $this->cache->get('core.packages', $time)) && $data !== $time) ? $data : [];
}
return $this->items;
}

Expand Down
5 changes: 1 addition & 4 deletions src/Routing/SettlementsPreloadMiddlewareBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

namespace Symbiotic\Routing;



use Symbiotic\Core\BootstrapInterface;
use Symbiotic\Core\CoreInterface;
use Symbiotic\Http\Kernel\PreloadKernelHandler;


class SettlementsPreloadMiddlewareBootstrap implements BootstrapInterface
{
public function bootstrap(CoreInterface $app): void
Expand All @@ -16,6 +15,4 @@ public function bootstrap(CoreInterface $app): void
$event->append(new KernelPreloadFindRouteMiddleware($app));
});
}


}
1 change: 1 addition & 0 deletions src/SimpleCacheFilesystem/SimpleCacheInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ interface SimpleCacheInterface extends \Psr\SimpleCache\CacheInterface
* @return mixed - Если в кеше будет найден ключ, то вернет из кеша или вернет результат фнукции $value и запишет в кеш
*/
public function remember($key, \Closure $value, $ttl = null);

}

0 comments on commit c1bf88e

Please sign in to comment.