Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b03cf952e | ||
|
|
33e3fba104 | ||
|
|
2a620798b3 |
@@ -11,5 +11,5 @@ composer require rmphp/kernel
|
|||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
composer require rmphp/kernel:"^2.0"
|
composer require rmphp/kernel:"^3.0"
|
||||||
```
|
```
|
||||||
|
|||||||
22
src/App.php
22
src/App.php
@@ -61,9 +61,7 @@ class App extends Main {
|
|||||||
$log = "Method ".$appHandler->className."/".$appHandler->methodName;
|
$log = "Method ".$appHandler->className."/".$appHandler->methodName;
|
||||||
}
|
}
|
||||||
$this->syslogger()->log("handlers", "OK - ".$log);
|
$this->syslogger()->log("handlers", "OK - ".$log);
|
||||||
/**
|
|
||||||
* 1. Если на этапе итерации уже получен ответ ResponseInterface - досрочно отдаем результат в эмиттер
|
|
||||||
*/
|
|
||||||
if($response instanceof ResponseInterface) {
|
if($response instanceof ResponseInterface) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
@@ -71,16 +69,7 @@ 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);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 3. Отдаем пустой результат если не определен шаблонизатор
|
|
||||||
*/
|
*/
|
||||||
return $this->defaultPage(404);
|
return $this->defaultPage(404);
|
||||||
}
|
}
|
||||||
@@ -101,7 +90,7 @@ class App extends Main {
|
|||||||
$this->syslogger()->error("Error: ".$error->getMessage()." : ".$error->getFile()." : ".$error->getLine());
|
$this->syslogger()->error("Error: ".$error->getMessage()." : ".$error->getFile()." : ".$error->getLine());
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 4. Отдаем ошибку без шаблона
|
* Отдаем после ошибки
|
||||||
*/
|
*/
|
||||||
return $this->defaultPage(501);
|
return $this->defaultPage(501);
|
||||||
}
|
}
|
||||||
@@ -112,10 +101,7 @@ class App extends Main {
|
|||||||
*/
|
*/
|
||||||
private function defaultPage(int $code) : ResponseInterface{
|
private function defaultPage(int $code) : ResponseInterface{
|
||||||
if(is_file($this->baseDir.'/'.getenv("PAGE".$code))){
|
if(is_file($this->baseDir.'/'.getenv("PAGE".$code))){
|
||||||
$body = $this->globals()->response()->getBody();
|
$this->globals()->response()->getBody()->write(file_get_contents($this->baseDir.'/'.getenv("PAGE".$code)));
|
||||||
$body->write(file_get_contents($this->baseDir.'/'.getenv("PAGE".$code)));
|
|
||||||
$body->rewind();
|
|
||||||
return $this->globals()->response()->withBody($body)->withStatus($code);
|
|
||||||
}
|
}
|
||||||
return $this->globals()->response()->withStatus($code);
|
return $this->globals()->response()->withStatus($code);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user