Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a620798b3 | ||
|
|
7658fc88e6 | ||
|
|
5c79d63d6c |
@@ -9,6 +9,7 @@ Stable version
|
||||
```bash
|
||||
composer require rmphp/kernel
|
||||
```
|
||||
|
||||
```bash
|
||||
composer require rmphp/kernel:"^1.0"
|
||||
composer require rmphp/kernel:"^2.0"
|
||||
```
|
||||
|
||||
18
src/App.php
18
src/App.php
@@ -4,6 +4,7 @@ declare(strict_types = 1);
|
||||
|
||||
namespace Rmphp\Kernel;
|
||||
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
@@ -48,7 +49,7 @@ class App extends Main {
|
||||
$this->syslogger()->log("handlers", "Err - Class ".$appHandler->className." is not exists");
|
||||
continue;
|
||||
}
|
||||
$controllers[$appRouteKey] = new $appHandler->className;
|
||||
$controllers[$appRouteKey] = ($this->container() instanceof ContainerInterface) ? $this->container()->get($appHandler->className) : new $appHandler->className;
|
||||
$log = "Class ".$appHandler->className;
|
||||
|
||||
if(!empty($appHandler->methodName)){
|
||||
@@ -73,10 +74,8 @@ class App extends Main {
|
||||
* 2. Если итерации закончились и задан обьект Content им создаем результат для эмиттера
|
||||
*/
|
||||
if($this->template() && !empty($this->template()->getResponse())){
|
||||
$body = $this->globals()->response()->getBody();
|
||||
$body->write($this->template()->getResponse());
|
||||
$body->rewind();
|
||||
return $this->globals()->response()->withBody($body);
|
||||
$this->globals()->response()->getBody()->write($this->template()->getResponse());
|
||||
return$this->globals()->response();
|
||||
}
|
||||
/**
|
||||
* 3. Отдаем пустой результат если не определен шаблонизатор
|
||||
@@ -87,7 +86,7 @@ class App extends Main {
|
||||
if($this->logger()) $this->logger()->warning($appException->getMessage()." on ".$appException->getFile().":".$appException->getLine());
|
||||
$this->syslogger()->warning("AppException: ".$appException->getMessage());
|
||||
}
|
||||
catch (\Exception $exception) {
|
||||
catch (\Exception|ContainerExceptionInterface $exception) {
|
||||
if($this->logger()) $this->logger()->warning($exception->getMessage()." on ".$exception->getFile().":".$exception->getLine());
|
||||
$this->syslogger()->warning("Exception: ".$exception->getMessage()." : ".$exception->getFile()." : ".$exception->getLine());
|
||||
}
|
||||
@@ -111,10 +110,7 @@ class App extends Main {
|
||||
*/
|
||||
private function defaultPage(int $code) : ResponseInterface{
|
||||
if(is_file($this->baseDir.'/'.getenv("PAGE".$code))){
|
||||
$body = $this->globals()->response()->getBody();
|
||||
$body->write(file_get_contents($this->baseDir.'/'.getenv("PAGE".$code)));
|
||||
$body->rewind();
|
||||
return $this->globals()->response()->withBody($body)->withStatus($code);
|
||||
$this->globals()->response()->getBody()->write(file_get_contents($this->baseDir.'/'.getenv("PAGE".$code)));
|
||||
}
|
||||
return $this->globals()->response()->withStatus($code);
|
||||
}
|
||||
@@ -167,7 +163,7 @@ class App extends Main {
|
||||
private function getActions(array $appNodes) : void {
|
||||
foreach ($appNodes as $appNode){
|
||||
|
||||
// по умолчанию точка монтирования ровна корню
|
||||
// по умолчанию точка монтирования от корня
|
||||
$mountKey = (!empty($appNode['key'])) ? $appNode['key'] : '/';
|
||||
|
||||
// если url начинается не с точки монтирования смотрим далее
|
||||
|
||||
Reference in New Issue
Block a user