mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-01 10:28:40 +00:00
Merge branch 'develop' of https://github.com/Karaka-Management/phpOMS into develop
This commit is contained in:
commit
04cb75cede
|
|
@ -40,6 +40,14 @@ class BaseStringL11nType implements \JsonSerializable
|
||||||
*/
|
*/
|
||||||
public string $title = '';
|
public string $title = '';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* String l11n
|
||||||
|
*
|
||||||
|
* @var string | BaseStringL11n
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public string | BaseStringL11n $l11n = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the l11n type required for an item?
|
* Is the l11n type required for an item?
|
||||||
*
|
*
|
||||||
|
|
@ -72,6 +80,44 @@ class BaseStringL11nType implements \JsonSerializable
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set l11n
|
||||||
|
*
|
||||||
|
* @param string|BaseStringL11n $l11n Tag article l11n
|
||||||
|
* @param string $lang Language
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||||
|
{
|
||||||
|
if ($l11n instanceof BaseStringL11n) {
|
||||||
|
$this->l11n = $l11n;
|
||||||
|
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
|
||||||
|
$this->l11n->content = $l11n;
|
||||||
|
$this->l11n->setLanguage($lang);
|
||||||
|
} else {
|
||||||
|
$this->l11n = new BaseStringL11n();
|
||||||
|
$this->l11n->content = $l11n;
|
||||||
|
$this->l11n->setLanguage($lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function getL11n() : string
|
||||||
|
{
|
||||||
|
if (!isset($this->l11n)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -275,7 +275,7 @@ final class L11nManager
|
||||||
int $divide = 1
|
int $divide = 1
|
||||||
) : string
|
) : string
|
||||||
{
|
{
|
||||||
$language = $l11n->getLanguage();
|
$language = $l11n->language;
|
||||||
$symbol ??= $l11n->getCurrency();
|
$symbol ??= $l11n->getCurrency();
|
||||||
|
|
||||||
if (\is_float($currency)) {
|
if (\is_float($currency)) {
|
||||||
|
|
|
||||||
|
|
@ -347,18 +347,6 @@ class Localization implements \JsonSerializable
|
||||||
$this->setDatetime($locale['datetime'] ?? []);
|
$this->setDatetime($locale['datetime'] ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get country
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public function getCountry() : string
|
|
||||||
{
|
|
||||||
return $this->country;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set country name
|
* Set country name
|
||||||
*
|
*
|
||||||
|
|
@ -409,18 +397,6 @@ class Localization implements \JsonSerializable
|
||||||
$this->timezone = $timezone;
|
$this->timezone = $timezone;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get language
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public function getLanguage() : string
|
|
||||||
{
|
|
||||||
return $this->language;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set language code
|
* Set language code
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ final class CliResponse extends ResponseAbstract implements RenderableInterface
|
||||||
*/
|
*/
|
||||||
public function setResponse(array $response) : void
|
public function setResponse(array $response) : void
|
||||||
{
|
{
|
||||||
$this->response = $response;
|
$this->data = $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -79,8 +79,8 @@ final class CliResponse extends ResponseAbstract implements RenderableInterface
|
||||||
*/
|
*/
|
||||||
public function remove(string $id) : bool
|
public function remove(string $id) : bool
|
||||||
{
|
{
|
||||||
if (isset($this->response[$id])) {
|
if (isset($this->data[$id])) {
|
||||||
unset($this->response[$id]);
|
unset($this->data[$id]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -134,7 +134,7 @@ final class CliResponse extends ResponseAbstract implements RenderableInterface
|
||||||
{
|
{
|
||||||
$render = '';
|
$render = '';
|
||||||
|
|
||||||
foreach ($this->response as $response) {
|
foreach ($this->data as $response) {
|
||||||
$render .= StringUtils::stringify($response);
|
$render .= StringUtils::stringify($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,7 +148,7 @@ final class CliResponse extends ResponseAbstract implements RenderableInterface
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
foreach ($this->response as $response) {
|
foreach ($this->data as $response) {
|
||||||
if ($response instanceof View) {
|
if ($response instanceof View) {
|
||||||
$result[] = $response->toArray();
|
$result[] = $response->toArray();
|
||||||
} elseif (\is_array($response) || \is_scalar($response)) {
|
} elseif (\is_array($response) || \is_scalar($response)) {
|
||||||
|
|
|
||||||
|
|
@ -404,7 +404,7 @@ final class HttpRequest extends RequestAbstract
|
||||||
public function getLocale() : string
|
public function getLocale() : string
|
||||||
{
|
{
|
||||||
if (!empty($this->locale)) {
|
if (!empty($this->locale)) {
|
||||||
return $this->locale = $this->header->l11n->getLanguage() . '_' . $this->header->l11n->getCountry();
|
return $this->locale = $this->header->l11n->language . '_' . $this->header->l11n->getCountry();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
|
if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ final class HttpResponse extends ResponseAbstract implements RenderableInterface
|
||||||
*/
|
*/
|
||||||
public function setResponse(array $response) : void
|
public function setResponse(array $response) : void
|
||||||
{
|
{
|
||||||
$this->response = $response;
|
$this->data = $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -73,8 +73,8 @@ final class HttpResponse extends ResponseAbstract implements RenderableInterface
|
||||||
*/
|
*/
|
||||||
public function remove(string $id) : bool
|
public function remove(string $id) : bool
|
||||||
{
|
{
|
||||||
if (isset($this->response[$id])) {
|
if (isset($this->data[$id])) {
|
||||||
unset($this->response[$id]);
|
unset($this->data[$id]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -143,7 +143,7 @@ final class HttpResponse extends ResponseAbstract implements RenderableInterface
|
||||||
private function getRaw(bool $optimize = false) : string
|
private function getRaw(bool $optimize = false) : string
|
||||||
{
|
{
|
||||||
$render = '';
|
$render = '';
|
||||||
foreach ($this->response as $response) {
|
foreach ($this->data as $response) {
|
||||||
// @note: Api functions return void -> null, this is where the null value is "ignored"/rendered as ''
|
// @note: Api functions return void -> null, this is where the null value is "ignored"/rendered as ''
|
||||||
$render .= StringUtils::stringify($response);
|
$render .= StringUtils::stringify($response);
|
||||||
}
|
}
|
||||||
|
|
@ -183,7 +183,7 @@ final class HttpResponse extends ResponseAbstract implements RenderableInterface
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
foreach ($this->response as $response) {
|
foreach ($this->data as $response) {
|
||||||
if ($response instanceof View) {
|
if ($response instanceof View) {
|
||||||
$result[] = $response->toArray();
|
$result[] = $response->toArray();
|
||||||
} elseif (\is_array($response) || \is_scalar($response)) {
|
} elseif (\is_array($response) || \is_scalar($response)) {
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
* @var array<int|string, mixed>
|
* @var array<int|string, mixed>
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected array $data = [];
|
public array $data = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Files data.
|
* Files data.
|
||||||
|
|
@ -48,7 +48,7 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
* @var array
|
* @var array
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected array $files = [];
|
public array $files = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request lock.
|
* Request lock.
|
||||||
|
|
@ -124,18 +124,6 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get data.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public function getDataArray() : array
|
|
||||||
{
|
|
||||||
return $this->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get data.
|
* Get data.
|
||||||
*
|
*
|
||||||
|
|
@ -380,30 +368,6 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
$this->lock = true;
|
$this->lock = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get request language.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public function getLanguage() : string
|
|
||||||
{
|
|
||||||
return $this->header->l11n->getLanguage();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get request language.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public function getCountry() : string
|
|
||||||
{
|
|
||||||
return $this->header->l11n->getCountry();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get request hash.
|
* Get request hash.
|
||||||
*
|
*
|
||||||
|
|
@ -442,44 +406,6 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
return $this->uri->__toString();
|
return $this->uri->__toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get files.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public function getFiles() : array
|
|
||||||
{
|
|
||||||
return $this->files;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get files by name.
|
|
||||||
*
|
|
||||||
* @param string $name File name
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public function getFile(string $name) : array
|
|
||||||
{
|
|
||||||
return $this->files[$name] ?? [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Has files.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public function hasFiles() : bool
|
|
||||||
{
|
|
||||||
return !empty($this->files);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add file to request
|
* Add file to request
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface
|
||||||
* @var array
|
* @var array
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected array $response = [];
|
public array $data = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Header.
|
* Header.
|
||||||
|
|
@ -53,7 +53,7 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface
|
||||||
*/
|
*/
|
||||||
public function get(mixed $id) : mixed
|
public function get(mixed $id) : mixed
|
||||||
{
|
{
|
||||||
return $this->response[$id] ?? null;
|
return $this->data[$id] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -69,9 +69,7 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface
|
||||||
*/
|
*/
|
||||||
public function set(mixed $key, mixed $response, bool $overwrite = false) : void
|
public function set(mixed $key, mixed $response, bool $overwrite = false) : void
|
||||||
{
|
{
|
||||||
// This is not working since the key contains :: from http://
|
$this->data[$key] = $response;
|
||||||
//$this->response = ArrayUtils::setArray((string) $key, $this->response, $response, ':', $overwrite);
|
|
||||||
$this->response[$key] = $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -106,7 +104,7 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface
|
||||||
return ISO639x1Enum::_EN;
|
return ISO639x1Enum::_EN;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->header->l11n->getLanguage();
|
return $this->header->l11n->language;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ final class SocketResponse extends ResponseAbstract implements RenderableInterfa
|
||||||
*/
|
*/
|
||||||
public function setResponse(array $response) : void
|
public function setResponse(array $response) : void
|
||||||
{
|
{
|
||||||
$this->response = $response;
|
$this->data = $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -56,8 +56,8 @@ final class SocketResponse extends ResponseAbstract implements RenderableInterfa
|
||||||
*/
|
*/
|
||||||
public function remove($id) : bool
|
public function remove($id) : bool
|
||||||
{
|
{
|
||||||
if (isset($this->response[$id])) {
|
if (isset($this->data[$id])) {
|
||||||
unset($this->response[$id]);
|
unset($this->data[$id]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -118,7 +118,7 @@ final class SocketResponse extends ResponseAbstract implements RenderableInterfa
|
||||||
{
|
{
|
||||||
$render = '';
|
$render = '';
|
||||||
|
|
||||||
foreach ($this->response as $key => $response) {
|
foreach ($this->data as $key => $response) {
|
||||||
$render .= StringUtils::stringify($response);
|
$render .= StringUtils::stringify($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,7 +157,7 @@ final class SocketResponse extends ResponseAbstract implements RenderableInterfa
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
foreach ($this->response as $response) {
|
foreach ($this->data as $response) {
|
||||||
if ($response instanceof View) {
|
if ($response instanceof View) {
|
||||||
$result[] = $response->toArray();
|
$result[] = $response->toArray();
|
||||||
} elseif (\is_array($response) || \is_scalar($response)) {
|
} elseif (\is_array($response) || \is_scalar($response)) {
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ abstract class ModuleAbstract
|
||||||
* @var string[]
|
* @var string[]
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected static array $providing = [];
|
public static array $providing = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dependencies.
|
* Dependencies.
|
||||||
|
|
@ -79,7 +79,7 @@ abstract class ModuleAbstract
|
||||||
* @var string[]
|
* @var string[]
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected static array $dependencies = [];
|
public static array $dependencies = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receiving modules from?
|
* Receiving modules from?
|
||||||
|
|
@ -87,7 +87,7 @@ abstract class ModuleAbstract
|
||||||
* @var string[]
|
* @var string[]
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected array $receiving = [];
|
public array $receiving = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Application instance.
|
* Application instance.
|
||||||
|
|
@ -220,12 +220,12 @@ abstract class ModuleAbstract
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||||
$response->set($request->uri->__toString(), [
|
$response->data[$request->uri->__toString()] = [
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'message' => $message,
|
'message' => $message,
|
||||||
'response' => $obj,
|
'response' => $obj,
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -246,12 +246,12 @@ abstract class ModuleAbstract
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||||
$response->set($request->uri->__toString(), [
|
$response->data[$request->uri->__toString()] = [
|
||||||
'status' => NotificationLevel::OK,
|
'status' => NotificationLevel::OK,
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SuccessfulCreate'),
|
'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SuccessfulCreate'),
|
||||||
'response' => $obj,
|
'response' => $obj,
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -272,12 +272,12 @@ abstract class ModuleAbstract
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||||
$response->set($request->uri->__toString(), [
|
$response->data[$request->uri->__toString()] = [
|
||||||
'status' => NotificationLevel::OK,
|
'status' => NotificationLevel::OK,
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SuccessfulUpdate'),
|
'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SuccessfulUpdate'),
|
||||||
'response' => $obj,
|
'response' => $obj,
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -298,12 +298,12 @@ abstract class ModuleAbstract
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||||
$response->set($request->uri->__toString(), [
|
$response->data[$request->uri->__toString()] = [
|
||||||
'status' => NotificationLevel::OK,
|
'status' => NotificationLevel::OK,
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SuccessfulDelete'),
|
'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SuccessfulDelete'),
|
||||||
'response' => $obj,
|
'response' => $obj,
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -324,12 +324,12 @@ abstract class ModuleAbstract
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||||
$response->set($request->uri->__toString(), [
|
$response->data[$request->uri->__toString()] = [
|
||||||
'status' => NotificationLevel::OK,
|
'status' => NotificationLevel::OK,
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SuccessfulRemove'),
|
'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SuccessfulRemove'),
|
||||||
'response' => $obj,
|
'response' => $obj,
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -350,12 +350,12 @@ abstract class ModuleAbstract
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||||
$response->set($request->uri->__toString(), [
|
$response->data[$request->uri->__toString()] = [
|
||||||
'status' => NotificationLevel::OK,
|
'status' => NotificationLevel::OK,
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SuccessfulReturn'),
|
'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SuccessfulReturn'),
|
||||||
'response' => $obj,
|
'response' => $obj,
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -376,12 +376,12 @@ abstract class ModuleAbstract
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||||
$response->set($request->uri->__toString(), [
|
$response->data[$request->uri->__toString()] = [
|
||||||
'status' => NotificationLevel::OK,
|
'status' => NotificationLevel::OK,
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SuccessfulAdd'),
|
'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SuccessfulAdd'),
|
||||||
'response' => $obj,
|
'response' => $obj,
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -402,12 +402,12 @@ abstract class ModuleAbstract
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||||
$response->set($request->uri->__toString(), [
|
$response->data[$request->uri->__toString()] = [
|
||||||
'status' => NotificationLevel::WARNING,
|
'status' => NotificationLevel::WARNING,
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'InvalidCreate'),
|
'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'InvalidCreate'),
|
||||||
'response' => $obj,
|
'response' => $obj,
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -428,12 +428,12 @@ abstract class ModuleAbstract
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||||
$response->set($request->uri->__toString(), [
|
$response->data[$request->uri->__toString()] = [
|
||||||
'status' => NotificationLevel::WARNING,
|
'status' => NotificationLevel::WARNING,
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'InvalidUpdate'),
|
'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'InvalidUpdate'),
|
||||||
'response' => $obj,
|
'response' => $obj,
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -454,12 +454,12 @@ abstract class ModuleAbstract
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||||
$response->set($request->uri->__toString(), [
|
$response->data[$request->uri->__toString()] = [
|
||||||
'status' => NotificationLevel::WARNING,
|
'status' => NotificationLevel::WARNING,
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'InvalidDelete'),
|
'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'InvalidDelete'),
|
||||||
'response' => $obj,
|
'response' => $obj,
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -480,12 +480,12 @@ abstract class ModuleAbstract
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||||
$response->set($request->uri->__toString(), [
|
$response->data[$request->uri->__toString()] = [
|
||||||
'status' => NotificationLevel::WARNING,
|
'status' => NotificationLevel::WARNING,
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'InvalidRemove'),
|
'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'InvalidRemove'),
|
||||||
'response' => $obj,
|
'response' => $obj,
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -506,12 +506,12 @@ abstract class ModuleAbstract
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||||
$response->set($request->uri->__toString(), [
|
$response->data[$request->uri->__toString()] = [
|
||||||
'status' => NotificationLevel::WARNING,
|
'status' => NotificationLevel::WARNING,
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'InvalidReturn'),
|
'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'InvalidReturn'),
|
||||||
'response' => $obj,
|
'response' => $obj,
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -532,12 +532,12 @@ abstract class ModuleAbstract
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||||
$response->set($request->uri->__toString(), [
|
$response->data[$request->uri->__toString()] = [
|
||||||
'status' => NotificationLevel::WARNING,
|
'status' => NotificationLevel::WARNING,
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'InvalidAdd'),
|
'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'InvalidAdd'),
|
||||||
'response' => $obj,
|
'response' => $obj,
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -558,12 +558,12 @@ abstract class ModuleAbstract
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||||
$response->set($request->uri->__toString(), [
|
$response->data[$request->uri->__toString()] = [
|
||||||
'status' => NotificationLevel::WARNING,
|
'status' => NotificationLevel::WARNING,
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'InvalidPermission'),
|
'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'InvalidPermission'),
|
||||||
'response' => $obj,
|
'response' => $obj,
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -580,7 +580,7 @@ abstract class ModuleAbstract
|
||||||
protected function fillJsonRawResponse(RequestAbstract $request, ResponseAbstract $response, mixed $obj) : void
|
protected function fillJsonRawResponse(RequestAbstract $request, ResponseAbstract $response, mixed $obj) : void
|
||||||
{
|
{
|
||||||
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||||
$response->set($request->uri->__toString(), $obj);
|
$response->data[$request->uri->__toString()] = $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ class View extends ViewAbstract
|
||||||
* @var array<string, mixed>
|
* @var array<string, mixed>
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected array $data = [];
|
public array $data = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View Localization.
|
* View Localization.
|
||||||
|
|
@ -47,7 +47,7 @@ class View extends ViewAbstract
|
||||||
* @var Localization
|
* @var Localization
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected Localization $l11n;
|
public Localization $l11n;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Application.
|
* Application.
|
||||||
|
|
@ -55,7 +55,7 @@ class View extends ViewAbstract
|
||||||
* @var L11nManager
|
* @var L11nManager
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected L11nManager $l11nManager;
|
public L11nManager $l11nManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request.
|
* Request.
|
||||||
|
|
@ -216,7 +216,7 @@ class View extends ViewAbstract
|
||||||
/** @var string $theme */
|
/** @var string $theme */
|
||||||
$theme = $theme ?? $this->theme;
|
$theme = $theme ?? $this->theme;
|
||||||
|
|
||||||
return $this->l11nManager->getText($this->l11n->getLanguage(), $module, $theme, $translation);
|
return $this->l11nManager->getText($this->l11n->language, $module, $theme, $translation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ final class CliRequestTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testDefault() : void
|
public function testDefault() : void
|
||||||
{
|
{
|
||||||
$request = new CliRequest();
|
$request = new CliRequest();
|
||||||
self::assertEquals('en', $request->getLanguage());
|
self::assertEquals('en', $request->header->l11n->language);
|
||||||
self::assertEquals(OSType::LINUX, $request->getOS());
|
self::assertEquals(OSType::LINUX, $request->getOS());
|
||||||
self::assertEquals('127.0.0.1', $request->getOrigin());
|
self::assertEquals('127.0.0.1', $request->getOrigin());
|
||||||
self::assertEmpty($request->getBody());
|
self::assertEmpty($request->getBody());
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,4 @@ use phpOMS\Message\Http\HttpRequest;
|
||||||
|
|
||||||
$request = HttpRequest::createFromSuperglobals();
|
$request = HttpRequest::createFromSuperglobals();
|
||||||
|
|
||||||
echo $request->getCountry();
|
echo $request->header->l11n->country;
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ final class HttpRequestTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
$_SERVER['HTTP_USER_AGENT'] = OSType::UNKNOWN . BrowserType::UNKNOWN;
|
$_SERVER['HTTP_USER_AGENT'] = OSType::UNKNOWN . BrowserType::UNKNOWN;
|
||||||
|
|
||||||
self::assertEquals('en', $request->getLanguage());
|
self::assertEquals('en', $request->header->l11n->language);
|
||||||
self::assertFalse($request->isMobile());
|
self::assertFalse($request->isMobile());
|
||||||
self::assertEquals(BrowserType::UNKNOWN, $request->getBrowser());
|
self::assertEquals(BrowserType::UNKNOWN, $request->getBrowser());
|
||||||
self::assertEquals(OSType::UNKNOWN, $request->getOS());
|
self::assertEquals(OSType::UNKNOWN, $request->getOS());
|
||||||
|
|
@ -51,7 +51,7 @@ final class HttpRequestTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertFalse(HttpRequest::isHttps());
|
self::assertFalse(HttpRequest::isHttps());
|
||||||
self::assertEquals([], $request->getHash());
|
self::assertEquals([], $request->getHash());
|
||||||
self::assertEmpty($request->getBody());
|
self::assertEmpty($request->getBody());
|
||||||
self::assertEmpty($request->getFiles());
|
self::assertEmpty($request->files);
|
||||||
self::assertEquals(RouteVerb::GET, $request->getRouteVerb());
|
self::assertEquals(RouteVerb::GET, $request->getRouteVerb());
|
||||||
self::assertEquals(RequestMethod::GET, $request->getMethod());
|
self::assertEquals(RequestMethod::GET, $request->getMethod());
|
||||||
self::assertInstanceOf('\phpOMS\Message\Http\HttpHeader', $request->header);
|
self::assertInstanceOf('\phpOMS\Message\Http\HttpHeader', $request->header);
|
||||||
|
|
@ -59,7 +59,7 @@ final class HttpRequestTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals('', $request->__toString());
|
self::assertEquals('', $request->__toString());
|
||||||
self::assertFalse($request->hasData('key'));
|
self::assertFalse($request->hasData('key'));
|
||||||
self::assertNull($request->getData('key'));
|
self::assertNull($request->getData('key'));
|
||||||
self::assertEquals('en', $request->getCountry());
|
self::assertEquals('en', $request->header->l11n->country);
|
||||||
self::assertEquals('en_US', $request->getLocale());
|
self::assertEquals('en_US', $request->getLocale());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,7 +162,7 @@ final class HttpRequestTest extends \PHPUnit\Framework\TestCase
|
||||||
$request->header->l11n = new Localization();
|
$request->header->l11n = new Localization();
|
||||||
$request->header->l11n->setLanguage(ISO639x1Enum::_DE);
|
$request->header->l11n->setLanguage(ISO639x1Enum::_DE);
|
||||||
|
|
||||||
self::assertEquals(ISO639x1Enum::_DE, $request->getLanguage());
|
self::assertEquals(ISO639x1Enum::_DE, $request->header->l11n->language);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ final class HttpResponseTest extends \PHPUnit\Framework\TestCase
|
||||||
$this->response->header->l11n = new Localization();
|
$this->response->header->l11n = new Localization();
|
||||||
$this->response->header->l11n->setLanguage(ISO639x1Enum::_DE);
|
$this->response->header->l11n->setLanguage(ISO639x1Enum::_DE);
|
||||||
|
|
||||||
self::assertEquals(ISO639x1Enum::_DE, $this->response->getLanguage());
|
self::assertEquals(ISO639x1Enum::_DE, $this->response->header->l11n->language);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ final class ResponseAbstractTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
self::assertNull($this->response->get('asdf'));
|
self::assertNull($this->response->get('asdf'));
|
||||||
self::assertEquals('', $this->response->getBody());
|
self::assertEquals('', $this->response->getBody());
|
||||||
self::assertTrue(ISO639x1Enum::isValidValue($this->response->getLanguage()));
|
self::assertTrue(ISO639x1Enum::isValidValue($this->response->header->l11n->language));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ final class ViewTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testHasData() : void
|
public function testHasData() : void
|
||||||
{
|
{
|
||||||
$view = new View($this->app->l11nManager);
|
$view = new View($this->app->l11nManager);
|
||||||
$view->addData('a', 1);
|
$view->data['a'] = 1;
|
||||||
|
|
||||||
self::assertTrue($view->hasData('a'));
|
self::assertTrue($view->hasData('a'));
|
||||||
self::assertFalse($view->hasData('b'));
|
self::assertFalse($view->hasData('b'));
|
||||||
|
|
@ -201,7 +201,7 @@ final class ViewTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
$view = new View($this->app->l11nManager);
|
$view = new View($this->app->l11nManager);
|
||||||
|
|
||||||
$view->setData('key', 'value');
|
$view->data['key'] = 'value';
|
||||||
self::assertEquals('value', $view->getData('key'));
|
self::assertEquals('value', $view->getData('key'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -214,7 +214,7 @@ final class ViewTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
$view = new View($this->app->l11nManager);
|
$view = new View($this->app->l11nManager);
|
||||||
|
|
||||||
self::assertTrue($view->addData('key2', 'valu2'));
|
self::assertTrue($view->data['key2'] = 'valu2');
|
||||||
self::assertEquals('valu2', $view->getData('key2'));
|
self::assertEquals('valu2', $view->getData('key2'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -227,8 +227,8 @@ final class ViewTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
$view = new View($this->app->l11nManager);
|
$view = new View($this->app->l11nManager);
|
||||||
|
|
||||||
$view->addData('key2', 'valu2');
|
$view->data['key2'] = 'valu2';
|
||||||
self::assertFalse($view->addData('key2', 'valu3'));
|
self::assertFalse($view->data['key2'] = 'valu3');
|
||||||
self::assertEquals('valu2', $view->getData('key2'));
|
self::assertEquals('valu2', $view->getData('key2'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -241,7 +241,7 @@ final class ViewTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
$view = new View($this->app->l11nManager);
|
$view = new View($this->app->l11nManager);
|
||||||
|
|
||||||
$view->addData('key2', 'valu2');
|
$view->data['key2'] = 'valu2';
|
||||||
self::assertTrue($view->removeData('key2'));
|
self::assertTrue($view->removeData('key2'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user