3 Commits
4.x ... 5.1

Author SHA1 Message Date
User
a2650ab53f 20250706#2 2025-07-06 20:12:09 +03:00
User
0558bb121d 20250706#1 2025-07-06 20:11:27 +03:00
User
b5ecb1fc86 20250622#1 2025-06-22 13:54:05 +03:00
5 changed files with 3 additions and 74 deletions

View File

@@ -9,5 +9,5 @@ composer create-project rmphp/skeleton project-name
```
```bash
composer create-project rmphp/skeleton:"^4.12" project-name
composer create-project rmphp/skeleton:"^5.1" project-name
```

View File

@@ -1,41 +0,0 @@
<?php
namespace Base\Application;
use Exception;
use ReflectionClass;
use Rmphp\Storage\Component\AbstractDataObject;
abstract class AbstractDTO extends AbstractDataObject {
/**
* @param array|object ...$data
* @return static
* @throws Exception
*/
public static function fromData(array|object ...$data) : static {
$array = array_map(function($item) {
return (is_object($item)) ? get_object_vars($item) : $item;
}, $data);
return self::fromArray(array_merge(...$array));
}
/**
* @param object $data
* @return static
* @throws Exception
*/
public static function fromObject(object $data) : static {
return self::fromArray(get_object_vars($data));
}
/**
* @param array $data
* @return static
* @throws Exception
*/
public static function fromArray(array $data) : static {
return self::fillObject(new ReflectionClass(static::class), new static(), $data);
}
}

View File

@@ -1,16 +0,0 @@
<?php
namespace Base\Application;
use Throwable;
class DTOException extends \Exception {
public array $data;
public function __construct($message="", $code=0, array $data = [], Throwable $previous=null) {
parent::__construct($message, $code, $previous);
$this->data = $data;
}
}

View File

@@ -3,33 +3,19 @@
namespace Base\Controllers;
use Base\Application\ApplicationException;
use Base\Application\DTOException;
use Base\Domain\DomainException;
use Exception;
use Throwable;
abstract class AbstractPageController extends AbstractController {
/**
* @param Exception $exception
* @param array $data
* @return void
*/
public function exceptionPage(Exception $exception, array $data = []) : void {
$this->logException($exception, $data);
$this->syslogger()->warning($exception->getMessage()." on ".$exception->getFile().":".$exception->getLine(), $data);
$this->template()->setSubtemplate("main", "/error/errpage.tpl", [
"errorText" => "<span style='color:red'>Error: ".$exception->getMessage()." (".$exception->getCode().")"."</span>"
]);
}
/**
* @param Throwable $e
* @return string
*/
public function checkError(Throwable $e) : string {
($e instanceof Exception) ? $this->logException($e) : $this->logError($e);
if($e instanceof DTOException || $e instanceof DomainException || $e instanceof ApplicationException) return $e->getMessage();
if($e instanceof DomainException || $e instanceof ApplicationException) return $e->getMessage();
return "Ошибка. Дата и время: ".date("d-m-Y H:i:s");
}
}

View File

@@ -17,7 +17,7 @@
"rmphp/router": "^2.0",
"rmphp/session": "^1.1",
"rmphp/redis": "^1.0",
"rmphp/storage": "^10.0",
"rmphp/storage": "^12.0",
"symfony/dotenv": "^6.2"
},
"autoload": {