resolved #1
This commit is contained in:
parent
0843fd83a5
commit
2b3f624199
|
@ -20,12 +20,12 @@ use mirzaev\minimal\core as minimal,
|
||||||
*
|
*
|
||||||
* @package ${REPO_OWNER}\${REPO_NAME}\controllers
|
* @package ${REPO_OWNER}\${REPO_NAME}\controllers
|
||||||
*
|
*
|
||||||
* @param session $session Instance of the session
|
* @param session $$session Instance of the session
|
||||||
* @param language $language Language
|
* @param language $$language Language
|
||||||
* @param response $response Response
|
* @param response $$response Response
|
||||||
* @param array $errors Registry of errors
|
* @param array $$errors Registry of errors
|
||||||
*
|
*
|
||||||
* @method void __construct(minimal $minimal, bool $initialize) Constructor
|
* @method void __construct(minimal $$minimal, bool $$initialize) Constructor
|
||||||
*
|
*
|
||||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||||
* @author ${REPO_OWNER} <mail@domain.zone>
|
* @author ${REPO_OWNER} <mail@domain.zone>
|
||||||
|
@ -35,35 +35,35 @@ class core extends controller
|
||||||
/**
|
/**
|
||||||
* Session
|
* Session
|
||||||
*
|
*
|
||||||
* @var session|null $session Instance of the session
|
* @var session|null $$session Instance of the session
|
||||||
*/
|
*/
|
||||||
protected readonly session $session;
|
protected readonly session $$session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language
|
* Language
|
||||||
*
|
*
|
||||||
* @var language $language Language
|
* @var language $$language Language
|
||||||
*/
|
*/
|
||||||
protected language $language = language::en;
|
protected language $$language = language::en;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Response
|
* Response
|
||||||
*
|
*
|
||||||
* @see https://wiki.php.net/rfc/property-hooks (find a table about backed and virtual hooks)
|
* @see https://wiki.php.net/rfc/property-hooks (find a table about backed and virtual hooks)
|
||||||
*
|
*
|
||||||
* @var response $response Response
|
* @var response $$response Response
|
||||||
*/
|
*/
|
||||||
protected response $response {
|
protected response $$response {
|
||||||
// Read
|
// Read
|
||||||
get => $this->response ??= $this->request->response();
|
get => $$this->response ??= $$this->request->response();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Errors
|
* Errors
|
||||||
*
|
*
|
||||||
* @var array $errors Registry of errors
|
* @var array $$errors Registry of errors
|
||||||
*/
|
*/
|
||||||
protected array $errors = [
|
protected array $$errors = [
|
||||||
'session' => [],
|
'session' => [],
|
||||||
'account' => []
|
'account' => []
|
||||||
];
|
];
|
||||||
|
@ -71,45 +71,45 @@ class core extends controller
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param minimal $minimal Instance of the MINIMAL
|
* @param minimal $$minimal Instance of the MINIMAL
|
||||||
* @param bool $initialize Initialize a controller?
|
* @param bool $$initialize Initialize a controller?
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(minimal $minimal, bool $initialize = true)
|
public function __construct(minimal $$minimal, bool $$initialize = true)
|
||||||
{
|
{
|
||||||
// Blocking requests from CloudFlare (better to write this blocking into nginx config file)
|
// Blocking requests from CloudFlare (better to write this blocking into nginx config file)
|
||||||
if (isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] === 'nginx-ssl early hints') return status::bruh->label;
|
if (isset($$_SERVER['HTTP_USER_AGENT']) && $$_SERVER['HTTP_USER_AGENT'] === 'nginx-ssl early hints') return status::bruh->label;
|
||||||
|
|
||||||
// For the extends system
|
// For the extends system
|
||||||
parent::__construct(core: $minimal);
|
parent::__construct(core: $$minimal);
|
||||||
|
|
||||||
if ($initialize) {
|
if ($$initialize) {
|
||||||
// Requestet initializing
|
// Requestet initializing
|
||||||
|
|
||||||
// Initializing core of the models
|
// Initializing core of the models
|
||||||
new models();
|
new models();
|
||||||
|
|
||||||
// Initializing of the date until which the session will be active
|
// Initializing of the date until which the session will be active
|
||||||
$expires = strtotime('+1 week');
|
$$expires = strtotime('+1 week');
|
||||||
|
|
||||||
// Initializing of default value of hash of the session
|
// Initializing of default value of hash of the session
|
||||||
$_COOKIE["session"] ??= null;
|
$$_COOKIE["session"] ??= null;
|
||||||
|
|
||||||
// Initializing of session
|
// Initializing of session
|
||||||
$this->session = new session($_COOKIE["session"], $expires, $this->errors['session']);
|
$$this->session = new session($$_COOKIE["session"], $$expires, $$this->errors['session']);
|
||||||
|
|
||||||
// Handle a problems with initializing a session
|
// Handle a problems with initializing a session
|
||||||
if (!empty($this->errors['session'])) die;
|
if (!empty($$this->errors['session'])) die;
|
||||||
else if ($_COOKIE["session"] !== $this->session->hash) {
|
else if ($$_COOKIE["session"] !== $$this->session->hash) {
|
||||||
// Hash of the session is changed (implies that the session has expired and recreated)
|
// Hash of the session is changed (implies that the session has expired and recreated)
|
||||||
|
|
||||||
// Write a new hash of the session to cookies
|
// Write a new hash of the session to cookies
|
||||||
setcookie(
|
setcookie(
|
||||||
'session',
|
'session',
|
||||||
$this->session->hash,
|
$$this->session->hash,
|
||||||
[
|
[
|
||||||
'expires' => $expires,
|
'expires' => $$expires,
|
||||||
'path' => '/',
|
'path' => '/',
|
||||||
'secure' => true,
|
'secure' => true,
|
||||||
'httponly' => true,
|
'httponly' => true,
|
||||||
|
@ -119,7 +119,7 @@ class core extends controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initializing of preprocessor of views
|
// Initializing of preprocessor of views
|
||||||
$this->view = new templater($this->session);
|
$$this->view = new templater($$this->session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ use mirzaev\minimal\http\enumerations\status;
|
||||||
*
|
*
|
||||||
* @package ${REPO_OWNER}\${REPO_NAME}\controllers
|
* @package ${REPO_OWNER}\${REPO_NAME}\controllers
|
||||||
*
|
*
|
||||||
* @param array $errors Registry of errors
|
* @param array $$errors Registry of errors
|
||||||
*
|
*
|
||||||
* @method null index() Main page
|
* @method null index() Main page
|
||||||
*
|
*
|
||||||
|
@ -27,9 +27,9 @@ final class index extends core
|
||||||
/**
|
/**
|
||||||
* Errors
|
* Errors
|
||||||
*
|
*
|
||||||
* @var array $errors Registry of errors
|
* @var array $$errors Registry of errors
|
||||||
*/
|
*/
|
||||||
protected array $errors = [
|
protected array $$errors = [
|
||||||
'session' => []
|
'session' => []
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -40,24 +40,24 @@ final class index extends core
|
||||||
*/
|
*/
|
||||||
public function index(): null
|
public function index(): null
|
||||||
{
|
{
|
||||||
if (str_contains($this->request->headers['accept'], content::any->value)) {
|
if (str_contains($$this->request->headers['accept'], content::any->value)) {
|
||||||
// Request for any response
|
// Request for any response
|
||||||
|
|
||||||
// Render page
|
// Render page
|
||||||
$page = $this->view->render('index.html');
|
$$page = $$this->view->render('index.html');
|
||||||
|
|
||||||
// Sending response
|
// Sending response
|
||||||
$this->response
|
$$this->response
|
||||||
->start()
|
->start()
|
||||||
->clean()
|
->clean()
|
||||||
->sse()
|
->sse()
|
||||||
->write($page)
|
->write($$page)
|
||||||
->validate($this->request)
|
->validate($$this->request)
|
||||||
?->body()
|
?->body()
|
||||||
->end();
|
->end();
|
||||||
|
|
||||||
// Deinitializing rendered page
|
// Deinitializing rendered page
|
||||||
unset($page);
|
unset($$page);
|
||||||
|
|
||||||
// Exit (success)
|
// Exit (success)
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -26,10 +26,10 @@ use exception;
|
||||||
* @package ${REPO_OWNER}\${REPO_NAME}\models
|
* @package ${REPO_OWNER}\${REPO_NAME}\models
|
||||||
*
|
*
|
||||||
* @param public ARANGODB Path to the file with ArangoDB session connection data
|
* @param public ARANGODB Path to the file with ArangoDB session connection data
|
||||||
* @param arangodb $arangodb Instance of the ArangoDB session
|
* @param arangodb $$arangodb Instance of the ArangoDB session
|
||||||
*
|
*
|
||||||
* @method void __construct(bool $initialize, ?arangodb $arangodb) Constructor
|
* @method void __construct(bool $$initialize, ?arangodb $$arangodb) Constructor
|
||||||
* @method _document|static|array|null read(string $filter, string $sort, int $amount, int $page, string $return, array $parameters, array &$errors) Read document from ArangoDB
|
* @method _document|static|array|null read(string $$filter, string $$sort, int $$amount, int $$page, string $$return, array $$parameters, array &$$errors) Read document from ArangoDB
|
||||||
*
|
*
|
||||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||||
* @author ${REPO_OWNER} <mail@domain.zone>
|
* @author ${REPO_OWNER} <mail@domain.zone>
|
||||||
|
@ -46,59 +46,59 @@ class core extends model
|
||||||
/**
|
/**
|
||||||
* ArangoDB
|
* ArangoDB
|
||||||
*
|
*
|
||||||
* @var arangodb $arangodb Instance of the ArangoDB session
|
* @var arangodb $$arangodb Instance of the ArangoDB session
|
||||||
*/
|
*/
|
||||||
protected static arangodb $arangodb;
|
protected static arangodb $$arangodb;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param bool $initialize Initialize a model?
|
* @param bool $$initialize Initialize a model?
|
||||||
* @param ?arangodb $arangodb Instance of the ArangoDB session
|
* @param ?arangodb $$arangodb Instance of the ArangoDB session
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(bool $initialize = true, ?arangodb $arangodb = null)
|
public function __construct(bool $$initialize = true, ?arangodb $$arangodb = null)
|
||||||
{
|
{
|
||||||
// For the extends system
|
// For the extends system
|
||||||
parent::__construct($initialize);
|
parent::__construct($$initialize);
|
||||||
|
|
||||||
if ($initialize) {
|
if ($$initialize) {
|
||||||
// Initializing is requested
|
// Initializing is requested
|
||||||
|
|
||||||
// Writing an instance of a session of ArangoDB to the property
|
// Writing an instance of a session of ArangoDB to the property
|
||||||
self::$arangodb = $arangodb ?? new arangodb(require static::ARANGODB);
|
self::$$arangodb = $$arangodb ?? new arangodb(require static::ARANGODB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read document from ArangoDB
|
* Read document from ArangoDB
|
||||||
*
|
*
|
||||||
* @param string $filter Expression for filtering (AQL)
|
* @param string $$filter Expression for filtering (AQL)
|
||||||
* @param string $sort Expression for sorting (AQL)
|
* @param string $$sort Expression for sorting (AQL)
|
||||||
* @param int $amount Amount of documents for collect
|
* @param int $$amount Amount of documents for collect
|
||||||
* @param int $page Page
|
* @param int $$page Page
|
||||||
* @param string $return Expression describing the parameters to return (AQL)
|
* @param string $$return Expression describing the parameters to return (AQL)
|
||||||
* @param array $parameters Binded parameters for placeholders ['placeholder' => parameter]
|
* @param array $$parameters Binded parameters for placeholders ['placeholder' => parameter]
|
||||||
* @param array &$errors Registry of errors
|
* @param array &$$errors Registry of errors
|
||||||
*
|
*
|
||||||
* @return mixed An array of instances of documents from ArangoDB, if they are found
|
* @return mixed An array of instances of documents from ArangoDB, if they are found
|
||||||
*/
|
*/
|
||||||
public static function _read(
|
public static function _read(
|
||||||
string $filter = '',
|
string $$filter = '',
|
||||||
string $sort = 'd.created DESC, d._key DESC',
|
string $$sort = 'd.created DESC, d._key DESC',
|
||||||
int $amount = 1,
|
int $$amount = 1,
|
||||||
int $page = 1,
|
int $$page = 1,
|
||||||
string $return = 'd',
|
string $$return = 'd',
|
||||||
array $parameters = [],
|
array $$parameters = [],
|
||||||
array &$errors = []
|
array &$$errors = []
|
||||||
): _document|static|array|null {
|
): _document|static|array|null {
|
||||||
try {
|
try {
|
||||||
if (collection::initialize(static::COLLECTION, static::TYPE)) {
|
if (collection::initialize(static::COLLECTION, static::TYPE)) {
|
||||||
// Initialized the collection
|
// Initialized the collection
|
||||||
|
|
||||||
// Read from ArangoDB
|
// Read from ArangoDB
|
||||||
$result = collection::execute(
|
$$result = collection::execute(
|
||||||
sprintf(
|
sprintf(
|
||||||
<<<'AQL'
|
<<<'AQL'
|
||||||
FOR d IN @@collection
|
FOR d IN @@collection
|
||||||
|
@ -107,45 +107,45 @@ class core extends model
|
||||||
LIMIT @offset, @amount
|
LIMIT @offset, @amount
|
||||||
RETURN %s
|
RETURN %s
|
||||||
AQL,
|
AQL,
|
||||||
empty($filter) ? '' : "FILTER $filter",
|
empty($$filter) ? '' : "FILTER $$filter",
|
||||||
empty($sort) ? '' : "SORT $sort",
|
empty($$sort) ? '' : "SORT $$sort",
|
||||||
empty($return) ? 'd' : $return
|
empty($$return) ? 'd' : $$return
|
||||||
),
|
),
|
||||||
[
|
[
|
||||||
'@collection' => static::COLLECTION,
|
'@collection' => static::COLLECTION,
|
||||||
'offset' => --$page <= 0 ? 0 : $page * $amount,
|
'offset' => --$$page <= 0 ? 0 : $$page * $$amount,
|
||||||
'amount' => $amount
|
'amount' => $$amount
|
||||||
] + $parameters,
|
] + $$parameters,
|
||||||
errors: $errors
|
errors: $$errors
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($amount === 1 && $result instanceof _document) {
|
if ($$amount === 1 && $$result instanceof _document) {
|
||||||
// Received only 1 document and @todo rebuild
|
// Received only 1 document and @todo rebuild
|
||||||
|
|
||||||
// Initializing the object
|
// Initializing the object
|
||||||
$object = new static;
|
$$object = new static;
|
||||||
|
|
||||||
if (method_exists($object, '__document')) {
|
if (method_exists($$object, '__document')) {
|
||||||
// Object can implement a document from ArangoDB
|
// Object can implement a document from ArangoDB
|
||||||
|
|
||||||
// Writing the instance of document from ArangoDB to the implement object
|
// Writing the instance of document from ArangoDB to the implement object
|
||||||
$object->__document($result);
|
$$object->__document($$result);
|
||||||
|
|
||||||
// Exit (success)
|
// Exit (success)
|
||||||
return $object;
|
return $$object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exit (success)
|
// Exit (success)
|
||||||
return $result;
|
return $$result;
|
||||||
} else throw new exception('Failed to initialize ' . static::TYPE . ' collection: ' . static::COLLECTION);
|
} else throw new exception('Failed to initialize ' . static::TYPE . ' collection: ' . static::COLLECTION);
|
||||||
} catch (exception $e) {
|
} catch (exception $$e) {
|
||||||
// Writing to registry of errors
|
// Writing to registry of errors
|
||||||
$errors[] = [
|
$$errors[] = [
|
||||||
'text' => $e->getMessage(),
|
'text' => $$e->getMessage(),
|
||||||
'file' => $e->getFile(),
|
'file' => $$e->getFile(),
|
||||||
'line' => $e->getLine(),
|
'line' => $$e->getLine(),
|
||||||
'stack' => $e->getTrace()
|
'stack' => $$e->getTrace()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,74 +156,74 @@ class core extends model
|
||||||
/**
|
/**
|
||||||
* Write
|
* Write
|
||||||
*
|
*
|
||||||
* @param string $name Name of the property
|
* @param string $$name Name of the property
|
||||||
* @param mixed $value Value of the property
|
* @param mixed $$value Value of the property
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __set(string $name, mixed $value = null): void
|
public function __set(string $$name, mixed $$value = null): void
|
||||||
{
|
{
|
||||||
match ($name) {
|
match ($$name) {
|
||||||
'arangodb' => (function () use ($value) {
|
'arangodb' => (function () use ($$value) {
|
||||||
if (isset(static::$arangodb)) throw new exception('Forbidden to reinitialize the ArangoDB session($this::$arangodb)', status::internal_server_error->value);
|
if (isset(static::$$arangodb)) throw new exception('Forbidden to reinitialize the ArangoDB session($$this::$$arangodb)', status::internal_server_error->value);
|
||||||
else if ($value instanceof arangodb) self::$arangodb = $value;
|
else if ($$value instanceof arangodb) self::$$arangodb = $$value;
|
||||||
else throw new exception('Session of connection to ArangoDB ($this::$arangodb) is need to be mirzaev\arangodb\connection', status::internal_server_error->value);
|
else throw new exception('Session of connection to ArangoDB ($$this::$$arangodb) is need to be mirzaev\arangodb\connection', status::internal_server_error->value);
|
||||||
})(),
|
})(),
|
||||||
default => parent::__set($name, $value)
|
default => parent::__set($$name, $$value)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read
|
* Read
|
||||||
*
|
*
|
||||||
* @param string $name Name of the property
|
* @param string $$name Name of the property
|
||||||
*
|
*
|
||||||
* @return mixed Content of the property, if they are found
|
* @return mixed Content of the property, if they are found
|
||||||
*/
|
*/
|
||||||
public function __get(string $name): mixed
|
public function __get(string $$name): mixed
|
||||||
{
|
{
|
||||||
return match ($name) {
|
return match ($$name) {
|
||||||
default => parent::__get($name)
|
default => parent::__get($$name)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete
|
* Delete
|
||||||
*
|
*
|
||||||
* @param string $name Name of the property
|
* @param string $$name Name of the property
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __unset(string $name): void
|
public function __unset(string $$name): void
|
||||||
{
|
{
|
||||||
// Deleting a property and exit (success)
|
// Deleting a property and exit (success)
|
||||||
parent::__unset($name);
|
parent::__unset($$name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check of initialization
|
* Check of initialization
|
||||||
*
|
*
|
||||||
* @param string $name Name of the property
|
* @param string $$name Name of the property
|
||||||
*
|
*
|
||||||
* @return bool The property is initialized?
|
* @return bool The property is initialized?
|
||||||
*/
|
*/
|
||||||
public function __isset(string $name): bool
|
public function __isset(string $$name): bool
|
||||||
{
|
{
|
||||||
// Check of initialization of the property and exit (success)
|
// Check of initialization of the property and exit (success)
|
||||||
return parent::__isset($name);
|
return parent::__isset($$name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call a static property or method
|
* Call a static property or method
|
||||||
*
|
*
|
||||||
* @param string $name Name of the property or the method
|
* @param string $$name Name of the property or the method
|
||||||
* @param array $arguments Arguments for the method
|
* @param array $$arguments Arguments for the method
|
||||||
*/
|
*/
|
||||||
public static function __callStatic(string $name, array $arguments): mixed
|
public static function __callStatic(string $$name, array $$arguments): mixed
|
||||||
{
|
{
|
||||||
return match ($name) {
|
return match ($$name) {
|
||||||
'arangodb' => (new static)->__get('arangodb'),
|
'arangodb' => (new static)->__get('arangodb'),
|
||||||
default => throw new exception("Not found: $name", 500)
|
default => throw new exception("Not found: $$name", 500)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ enum language
|
||||||
*
|
*
|
||||||
* Initialize label of the language
|
* Initialize label of the language
|
||||||
*
|
*
|
||||||
* @param language|null $language Language into which to translate
|
* @param language|null $$language Language into which to translate
|
||||||
*
|
*
|
||||||
* @return string Translated label of the language
|
* @return string Translated label of the language
|
||||||
*
|
*
|
||||||
|
@ -33,15 +33,15 @@ enum language
|
||||||
* 1. More languages
|
* 1. More languages
|
||||||
* 2. Cases???
|
* 2. Cases???
|
||||||
*/
|
*/
|
||||||
public function label(?language $language = language::en): string
|
public function label(?language $$language = language::en): string
|
||||||
{
|
{
|
||||||
// Exit (success)
|
// Exit (success)
|
||||||
return match ($this) {
|
return match ($$this) {
|
||||||
language::en => match ($language) {
|
language::en => match ($$language) {
|
||||||
language::en => 'English',
|
language::en => 'English',
|
||||||
language::ru => 'Английский'
|
language::ru => 'Английский'
|
||||||
},
|
},
|
||||||
language::ru => match ($language) {
|
language::ru => match ($$language) {
|
||||||
language::en => 'Russian',
|
language::en => 'Russian',
|
||||||
language::ru => 'Русский'
|
language::ru => 'Русский'
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ use ArangoDBClient\Document as _document;
|
||||||
*
|
*
|
||||||
* Interface for implementing a document instance from ArangoDB
|
* Interface for implementing a document instance from ArangoDB
|
||||||
*
|
*
|
||||||
* @param _document $document An instance of the ArangoDB document from ArangoDB (protected readonly)
|
* @param _document $$document An instance of the ArangoDB document from ArangoDB (protected readonly)
|
||||||
*
|
*
|
||||||
* @package ${REPO_OWNER}\${REPO_NAME}\models\interfaces
|
* @package ${REPO_OWNER}\${REPO_NAME}\models\interfaces
|
||||||
*
|
*
|
||||||
|
@ -26,23 +26,23 @@ interface document
|
||||||
*
|
*
|
||||||
* Write a property into an instance of the ArangoDB document
|
* Write a property into an instance of the ArangoDB document
|
||||||
*
|
*
|
||||||
* @param string $name Name of the property
|
* @param string $$name Name of the property
|
||||||
* @param mixed $value Content of the property
|
* @param mixed $$value Content of the property
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __set(string $name, mixed $value = null): void;
|
public function __set(string $$name, mixed $$value = null): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read
|
* Read
|
||||||
*
|
*
|
||||||
* Read a property from an instance of the ArangoDB docuemnt
|
* Read a property from an instance of the ArangoDB docuemnt
|
||||||
*
|
*
|
||||||
* @param string $name Name of the property
|
* @param string $$name Name of the property
|
||||||
*
|
*
|
||||||
* @return mixed Content of the property
|
* @return mixed Content of the property
|
||||||
*/
|
*/
|
||||||
public function __get(string $name): mixed;
|
public function __get(string $$name): mixed;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,32 +50,32 @@ interface document
|
||||||
*
|
*
|
||||||
* Deinitialize the property in an instance of the ArangoDB document
|
* Deinitialize the property in an instance of the ArangoDB document
|
||||||
*
|
*
|
||||||
* @param string $name Name of the property
|
* @param string $$name Name of the property
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __unset(string $name): void;
|
public function __unset(string $$name): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check of initialization
|
* Check of initialization
|
||||||
*
|
*
|
||||||
* Check of initialization of the property into an instance of the ArangoDB document
|
* Check of initialization of the property into an instance of the ArangoDB document
|
||||||
*
|
*
|
||||||
* @param string $name Name of the property
|
* @param string $$name Name of the property
|
||||||
*
|
*
|
||||||
* @return bool The property is initialized?
|
* @return bool The property is initialized?
|
||||||
*/
|
*/
|
||||||
public function __isset(string $name): bool;
|
public function __isset(string $$name): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a method
|
* Execute a method
|
||||||
*
|
*
|
||||||
* Execute a method from an instance of the ArangoDB document
|
* Execute a method from an instance of the ArangoDB document
|
||||||
*
|
*
|
||||||
* @param string $name Name of the method
|
* @param string $$name Name of the method
|
||||||
* @param array $arguments Arguments for the method
|
* @param array $$arguments Arguments for the method
|
||||||
*
|
*
|
||||||
* @return mixed Result of execution of the method
|
* @return mixed Result of execution of the method
|
||||||
*/
|
*/
|
||||||
public function __call(string $name, array $arguments = []): mixed;
|
public function __call(string $$name, array $$arguments = []): mixed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,9 @@ use exception;
|
||||||
* @param string COLLECTION Name of the collection in ArangoDB
|
* @param string COLLECTION Name of the collection in ArangoDB
|
||||||
* @param verification VERIFICATION Type of session verification
|
* @param verification VERIFICATION Type of session verification
|
||||||
*
|
*
|
||||||
* @method void __construct(?string $hash, ?int $expires, array &$errors) Constructor
|
* @method void __construct(?string $$hash, ?int $$expires, array &$$errors) Constructor
|
||||||
* @method document|null hash(string $hash, array &$errors) Search by hash
|
* @method document|null hash(string $$hash, array &$$errors) Search by hash
|
||||||
* @method document|null address(string $address, array &$errors) Search by IP-address
|
* @method document|null address(string $$address, array &$$errors) Search by IP-address
|
||||||
*
|
*
|
||||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||||
* @author ${REPO_OWNER} <mail@domain.zone>
|
* @author ${REPO_OWNER} <mail@domain.zone>
|
||||||
|
@ -62,47 +62,47 @@ final class session extends core implements document_interface, collection_inter
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* Initialize session and write into the $this->document property
|
* Initialize session and write into the $$this->document property
|
||||||
*
|
*
|
||||||
* @param ?string $hash Hash of the session in ArangoDB
|
* @param ?string $$hash Hash of the session in ArangoDB
|
||||||
* @param ?int $expires Date of expiring of the session (used for creating a new session)
|
* @param ?int $$expires Date of expiring of the session (used for creating a new session)
|
||||||
* @param array &$errors Registry of errors
|
* @param array &$$errors Registry of errors
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(?string $hash = null, ?int $expires = null, array &$errors = [])
|
public function __construct(?string $$hash = null, ?int $$expires = null, array &$$errors = [])
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (collection::initialize(static::COLLECTION, static::TYPE, errors: $errors)) {
|
if (collection::initialize(static::COLLECTION, static::TYPE, errors: $$errors)) {
|
||||||
// Initialized the collection
|
// Initialized the collection
|
||||||
|
|
||||||
if (isset($hash) && $document = $this->hash($hash, errors: $errors)) {
|
if (isset($$hash) && $$document = $$this->hash($$hash, errors: $$errors)) {
|
||||||
// Found the instance of the ArangoDB document of session and received a session hash
|
// Found the instance of the ArangoDB document of session and received a session hash
|
||||||
|
|
||||||
// Writing document instance of the session from ArangoDB to the property of the implementing object
|
// Writing document instance of the session from ArangoDB to the property of the implementing object
|
||||||
$this->__document($document);
|
$$this->__document($$document);
|
||||||
} else if (static::VERIFICATION === verification::hash_else_address && $document = $this->address($_SERVER['REMOTE_ADDR'], errors: $errors)) {
|
} else if (static::VERIFICATION === verification::hash_else_address && $$document = $$this->address($$_SERVER['REMOTE_ADDR'], errors: $$errors)) {
|
||||||
// Found the instance of the ArangoDB document of session and received a session hash
|
// Found the instance of the ArangoDB document of session and received a session hash
|
||||||
|
|
||||||
// Writing document instance of the session from ArangoDB to the property of the implementing object
|
// Writing document instance of the session from ArangoDB to the property of the implementing object
|
||||||
$this->__document($document);
|
$$this->__document($$document);
|
||||||
} else {
|
} else {
|
||||||
// Not found the instance of the ArangoDB document of session
|
// Not found the instance of the ArangoDB document of session
|
||||||
|
|
||||||
// Initializing a new session and write they into ArangoDB
|
// Initializing a new session and write they into ArangoDB
|
||||||
$_id = document::write(
|
$$_id = document::write(
|
||||||
static::COLLECTION,
|
static::COLLECTION,
|
||||||
[
|
[
|
||||||
'active' => true,
|
'active' => true,
|
||||||
'expires' => $expires ?? time() + 604800,
|
'expires' => $$expires ?? time() + 604800,
|
||||||
'address' => $_SERVER['REMOTE_ADDR'],
|
'address' => $$_SERVER['REMOTE_ADDR'],
|
||||||
'x-forwarded-for' => $_SERVER['HTTP_X_FORWARDED_FOR'] ?? null,
|
'x-forwarded-for' => $$_SERVER['HTTP_X_FORWARDED_FOR'] ?? null,
|
||||||
'referer' => $_SERVER['HTTP_REFERER'] ?? null,
|
'referer' => $$_SERVER['HTTP_REFERER'] ?? null,
|
||||||
'useragent' => $_SERVER['HTTP_USER_AGENT'] ?? null
|
'useragent' => $$_SERVER['HTTP_USER_AGENT'] ?? null
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($session = collection::execute(
|
if ($$session = collection::execute(
|
||||||
<<<'AQL'
|
<<<'AQL'
|
||||||
FOR d IN @@collection
|
FOR d IN @@collection
|
||||||
FILTER d._id == @_id && d.expires > @time && d.active == true
|
FILTER d._id == @_id && d.expires > @time && d.active == true
|
||||||
|
@ -110,32 +110,32 @@ final class session extends core implements document_interface, collection_inter
|
||||||
AQL,
|
AQL,
|
||||||
[
|
[
|
||||||
'@collection' => static::COLLECTION,
|
'@collection' => static::COLLECTION,
|
||||||
'_id' => $_id,
|
'_id' => $$_id,
|
||||||
'time' => time()
|
'time' => time()
|
||||||
],
|
],
|
||||||
errors: $errors
|
errors: $$errors
|
||||||
)) {
|
)) {
|
||||||
// Found the instance of just created new session
|
// Found the instance of just created new session
|
||||||
|
|
||||||
// Generating a hash and write into the instance of the ArangoDB document of session property
|
// Generating a hash and write into the instance of the ArangoDB document of session property
|
||||||
$session->hash = sodium_bin2hex(sodium_crypto_generichash($_id));
|
$$session->hash = sodium_bin2hex(sodium_crypto_generichash($$_id));
|
||||||
|
|
||||||
if (document::update($session, errors: $errors)) {
|
if (document::update($$session, errors: $$errors)) {
|
||||||
// Writed to ArangoDB
|
// Writed to ArangoDB
|
||||||
|
|
||||||
// Writing instance of the session document from ArangoDB to the property of the implementing object
|
// Writing instance of the session document from ArangoDB to the property of the implementing object
|
||||||
$this->__document($session);
|
$$this->__document($$session);
|
||||||
} else throw new exception('Failed to write the session data');
|
} else throw new exception('Failed to write the session data');
|
||||||
} else throw new exception('Failed to create or find just created session');
|
} else throw new exception('Failed to create or find just created session');
|
||||||
}
|
}
|
||||||
} else throw new exception('Failed to initialize ' . static::TYPE . ' collection: ' . static::COLLECTION);
|
} else throw new exception('Failed to initialize ' . static::TYPE . ' collection: ' . static::COLLECTION);
|
||||||
} catch (exception $e) {
|
} catch (exception $$e) {
|
||||||
// Writing to the registry of errors
|
// Writing to the registry of errors
|
||||||
$errors[] = [
|
$$errors[] = [
|
||||||
'text' => $e->getMessage(),
|
'text' => $$e->getMessage(),
|
||||||
'file' => $e->getFile(),
|
'file' => $$e->getFile(),
|
||||||
'line' => $e->getLine(),
|
'line' => $$e->getLine(),
|
||||||
'stack' => $e->getTrace()
|
'stack' => $$e->getTrace()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,15 +145,15 @@ final class session extends core implements document_interface, collection_inter
|
||||||
*
|
*
|
||||||
* Search for the session in ArangoDB by hash
|
* Search for the session in ArangoDB by hash
|
||||||
*
|
*
|
||||||
* @param string $hash Hash of the session in ArangoDB
|
* @param string $$hash Hash of the session in ArangoDB
|
||||||
* @param array &$errors Registry of errors
|
* @param array &$$errors Registry of errors
|
||||||
*
|
*
|
||||||
* @return _document|null instance of document of the session in ArangoDB
|
* @return _document|null instance of document of the session in ArangoDB
|
||||||
*/
|
*/
|
||||||
public static function hash(string $hash, array &$errors = []): ?_document
|
public static function hash(string $$hash, array &$$errors = []): ?_document
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (collection::initialize(static::COLLECTION, static::TYPE, errors: $errors)) {
|
if (collection::initialize(static::COLLECTION, static::TYPE, errors: $$errors)) {
|
||||||
// Collection initialized
|
// Collection initialized
|
||||||
|
|
||||||
// Search the session data in ArangoDB
|
// Search the session data in ArangoDB
|
||||||
|
@ -165,19 +165,19 @@ final class session extends core implements document_interface, collection_inter
|
||||||
AQL,
|
AQL,
|
||||||
[
|
[
|
||||||
'@collection' => static::COLLECTION,
|
'@collection' => static::COLLECTION,
|
||||||
'hash' => $hash,
|
'hash' => $$hash,
|
||||||
'time' => time()
|
'time' => time()
|
||||||
],
|
],
|
||||||
errors: $errors
|
errors: $$errors
|
||||||
);
|
);
|
||||||
} else throw new exception('Failed to initialize ' . static::TYPE . ' collection: ' . static::COLLECTION);
|
} else throw new exception('Failed to initialize ' . static::TYPE . ' collection: ' . static::COLLECTION);
|
||||||
} catch (exception $e) {
|
} catch (exception $$e) {
|
||||||
// Writing to the registry of errors
|
// Writing to the registry of errors
|
||||||
$errors[] = [
|
$$errors[] = [
|
||||||
'text' => $e->getMessage(),
|
'text' => $$e->getMessage(),
|
||||||
'file' => $e->getFile(),
|
'file' => $$e->getFile(),
|
||||||
'line' => $e->getLine(),
|
'line' => $$e->getLine(),
|
||||||
'stack' => $e->getTrace()
|
'stack' => $$e->getTrace()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,15 +190,15 @@ final class session extends core implements document_interface, collection_inter
|
||||||
*
|
*
|
||||||
* Search for the session in ArangoDB by IP-address
|
* Search for the session in ArangoDB by IP-address
|
||||||
*
|
*
|
||||||
* @param string $address IP-address writed to the session in ArangoDB
|
* @param string $$address IP-address writed to the session in ArangoDB
|
||||||
* @param array &$errors Registry of errors
|
* @param array &$$errors Registry of errors
|
||||||
*
|
*
|
||||||
* @return _document|null instance of document of the session in ArangoDB
|
* @return _document|null instance of document of the session in ArangoDB
|
||||||
*/
|
*/
|
||||||
public static function address(string $address, array &$errors = []): ?_document
|
public static function address(string $$address, array &$$errors = []): ?_document
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (collection::initialize(static::COLLECTION, static::TYPE, errors: $errors)) {
|
if (collection::initialize(static::COLLECTION, static::TYPE, errors: $$errors)) {
|
||||||
// Collection initialized
|
// Collection initialized
|
||||||
|
|
||||||
// Search the session data in ArangoDB
|
// Search the session data in ArangoDB
|
||||||
|
@ -212,19 +212,19 @@ final class session extends core implements document_interface, collection_inter
|
||||||
AQL,
|
AQL,
|
||||||
[
|
[
|
||||||
'@collection' => static::COLLECTION,
|
'@collection' => static::COLLECTION,
|
||||||
'address' => $address,
|
'address' => $$address,
|
||||||
'time' => time()
|
'time' => time()
|
||||||
],
|
],
|
||||||
errors: $errors
|
errors: $$errors
|
||||||
);
|
);
|
||||||
} else throw new exception('Failed to initialize ' . static::TYPE . ' collection: ' . static::COLLECTION);
|
} else throw new exception('Failed to initialize ' . static::TYPE . ' collection: ' . static::COLLECTION);
|
||||||
} catch (exception $e) {
|
} catch (exception $$e) {
|
||||||
// Writing to the registry of errors
|
// Writing to the registry of errors
|
||||||
$errors[] = [
|
$$errors[] = [
|
||||||
'text' => $e->getMessage(),
|
'text' => $$e->getMessage(),
|
||||||
'file' => $e->getFile(),
|
'file' => $$e->getFile(),
|
||||||
'line' => $e->getLine(),
|
'line' => $$e->getLine(),
|
||||||
'stack' => $e->getTrace()
|
'stack' => $$e->getTrace()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,39 +42,39 @@ trait buffer
|
||||||
/**
|
/**
|
||||||
* Write to buffer of the document
|
* Write to buffer of the document
|
||||||
*
|
*
|
||||||
* @param array $data Data for writing (merge)
|
* @param array $$data Data for writing (merge)
|
||||||
* @param array &$errors Registry of errors
|
* @param array &$$errors Registry of errors
|
||||||
*
|
*
|
||||||
* @return bool Is data has written into the document from ArangoDB?
|
* @return bool Is data has written into the document from ArangoDB?
|
||||||
*/
|
*/
|
||||||
public function write(array $data, array &$errors = []): bool
|
public function write(array $$data, array &$$errors = []): bool
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (collection::initialize(static::COLLECTION, static::TYPE, errors: $errors)) {
|
if (collection::initialize(static::COLLECTION, static::TYPE, errors: $$errors)) {
|
||||||
// Initialized the collection
|
// Initialized the collection
|
||||||
|
|
||||||
// Is the instance of the document from ArangoDB are initialized?
|
// Is the instance of the document from ArangoDB are initialized?
|
||||||
if (!isset($this->document)) throw new exception('The instance of the sessoin document from ArangoDB is not initialized');
|
if (!isset($$this->document)) throw new exception('The instance of the sessoin document from ArangoDB is not initialized');
|
||||||
|
|
||||||
// Writing data into buffer of the instance of the document from ArangoDB
|
// Writing data into buffer of the instance of the document from ArangoDB
|
||||||
$this->document->buffer = array_replace_recursive($this->document->buffer ?? [], $data);
|
$$this->document->buffer = array_replace_recursive($$this->document->buffer ?? [], $$data);
|
||||||
|
|
||||||
// Is the buffer of the instance of the document from ArangoDB exceed 10 megabytes?
|
// Is the buffer of the instance of the document from ArangoDB exceed 10 megabytes?
|
||||||
if (mb_strlen(json_encode($this->document->buffer)) > 10485760) throw new exception('The buffer size exceeds 10 megabytes');
|
if (mb_strlen(json_encode($$this->document->buffer)) > 10485760) throw new exception('The buffer size exceeds 10 megabytes');
|
||||||
|
|
||||||
// Serializing parameters
|
// Serializing parameters
|
||||||
if ($this->document->language instanceof language) $this->document->language = $this->document->language->name;
|
if ($$this->document->language instanceof language) $$this->document->language = $$this->document->language->name;
|
||||||
|
|
||||||
// Writing to ArangoDB and exit (success)
|
// Writing to ArangoDB and exit (success)
|
||||||
return document::update($this->document, errors: $errors);
|
return document::update($$this->document, errors: $$errors);
|
||||||
} else throw new exception('Failed to initialize ' . static::TYPE . ' collection: ' . static::COLLECTION);
|
} else throw new exception('Failed to initialize ' . static::TYPE . ' collection: ' . static::COLLECTION);
|
||||||
} catch (exception $e) {
|
} catch (exception $$e) {
|
||||||
// Writing to the registry of errors
|
// Writing to the registry of errors
|
||||||
$errors[] = [
|
$$errors[] = [
|
||||||
'text' => $e->getMessage(),
|
'text' => $$e->getMessage(),
|
||||||
'file' => $e->getFile(),
|
'file' => $$e->getFile(),
|
||||||
'line' => $e->getLine(),
|
'line' => $$e->getLine(),
|
||||||
'stack' => $e->getTrace()
|
'stack' => $$e->getTrace()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ use exception;
|
||||||
*
|
*
|
||||||
* @uses document_interface
|
* @uses document_interface
|
||||||
*
|
*
|
||||||
* @var protected readonly _document|null $document An instance of the ArangoDB document
|
* @var protected readonly _document|null $$document An instance of the ArangoDB document
|
||||||
*
|
*
|
||||||
* @package ${REPO_OWNER}\${REPO_NAME}\models\traits
|
* @package ${REPO_OWNER}\${REPO_NAME}\models\traits
|
||||||
*
|
*
|
||||||
|
@ -37,87 +37,87 @@ trait document
|
||||||
/**
|
/**
|
||||||
* Document
|
* Document
|
||||||
*
|
*
|
||||||
* @var _document $document An instance of the document from ArangoDB
|
* @var _document $$document An instance of the document from ArangoDB
|
||||||
*/
|
*/
|
||||||
protected readonly _document $document;
|
protected readonly _document $$document;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param bool $initialize Initialize a model?
|
* @param bool $$initialize Initialize a model?
|
||||||
* @param ?arangodb $arangodb Instance of a session of ArangoDB
|
* @param ?arangodb $$arangodb Instance of a session of ArangoDB
|
||||||
* @param _document|null|false $document An instance of the ArangoDB document
|
* @param _document|null|false $$document An instance of the ArangoDB document
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
bool $initialize = true,
|
bool $$initialize = true,
|
||||||
?arangodb $arangodb = null,
|
?arangodb $$arangodb = null,
|
||||||
_document|null|false $document = false
|
_document|null|false $$document = false
|
||||||
) {
|
) {
|
||||||
// For the extends system
|
// For the extends system
|
||||||
parent::__construct($initialize, $arangodb);
|
parent::__construct($$initialize, $$arangodb);
|
||||||
|
|
||||||
// Writing to the property
|
// Writing to the property
|
||||||
if ($document instanceof _document) $this->__document($document);
|
if ($$document instanceof _document) $$this->__document($$document);
|
||||||
else if ($document === null) throw new exception('Failed to initialize an instance of the document from ArangoDB');
|
else if ($$document === null) throw new exception('Failed to initialize an instance of the document from ArangoDB');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write or read document
|
* Write or read document
|
||||||
*
|
*
|
||||||
* @param _document|null $document Instance of document from ArangoDB
|
* @param _document|null $$document Instance of document from ArangoDB
|
||||||
*
|
*
|
||||||
* @return _document|null Instance of document from ArangoDB
|
* @return _document|null Instance of document from ArangoDB
|
||||||
*/
|
*/
|
||||||
public function __document(?_document $document = null): ?_document
|
public function __document(?_document $$document = null): ?_document
|
||||||
{
|
{
|
||||||
// Writing a property storing a document instance to ArangoDB
|
// Writing a property storing a document instance to ArangoDB
|
||||||
if ($document) $this->document ??= $document;
|
if ($$document) $$this->document ??= $$document;
|
||||||
|
|
||||||
// Read a property storing a document instance to ArangoDB and exit (success)
|
// Read a property storing a document instance to ArangoDB and exit (success)
|
||||||
return $this->document ?? null;
|
return $$this->document ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect
|
* Connect
|
||||||
*
|
*
|
||||||
* @param collecton_interface $document Document
|
* @param collecton_interface $$document Document
|
||||||
* @param array &$errors Registry of errors
|
* @param array &$$errors Registry of errors
|
||||||
*
|
*
|
||||||
* @return string|null The identifier of the created edge of the "connect" collection, if created
|
* @return string|null The identifier of the created edge of the "connect" collection, if created
|
||||||
*/
|
*/
|
||||||
public function connect(collection_interface $document, array &$errors = []): ?string
|
public function connect(collection_interface $$document, array &$$errors = []): ?string
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (collection::initialize(static::COLLECTION, static::TYPE, errors: $errors)) {
|
if (collection::initialize(static::COLLECTION, static::TYPE, errors: $$errors)) {
|
||||||
if (collection::initialize(connect::COLLECTION, connect::TYPE, errors: $errors)) {
|
if (collection::initialize(connect::COLLECTION, connect::TYPE, errors: $$errors)) {
|
||||||
if (collection::initialize($document::COLLECTION, $document::TYPE, errors: $errors)) {
|
if (collection::initialize($$document::COLLECTION, $$document::TYPE, errors: $$errors)) {
|
||||||
// Initialized collections
|
// Initialized collections
|
||||||
|
|
||||||
if ($this->document instanceof _document) {
|
if ($$this->document instanceof _document) {
|
||||||
// Initialized instance of the document from ArangoDB
|
// Initialized instance of the document from ArangoDB
|
||||||
|
|
||||||
// Writing document and exit (success)
|
// Writing document and exit (success)
|
||||||
return framework_document::write(
|
return framework_document::write(
|
||||||
connect::COLLECTION,
|
connect::COLLECTION,
|
||||||
[
|
[
|
||||||
'_from' => $document->getId(),
|
'_from' => $$document->getId(),
|
||||||
'_to' => $this->document->getId()
|
'_to' => $$this->document->getId()
|
||||||
],
|
],
|
||||||
errors: $errors
|
errors: $$errors
|
||||||
);
|
);
|
||||||
} else throw new exception('The instance of the document from ArangoDB is not initialized');
|
} else throw new exception('The instance of the document from ArangoDB is not initialized');
|
||||||
} else throw new exception('Failed to initialize ' . $document::TYPE . ' collection: ' . $document::COLLECTION);
|
} else throw new exception('Failed to initialize ' . $$document::TYPE . ' collection: ' . $$document::COLLECTION);
|
||||||
} else throw new exception('Failed to initialize ' . connect::TYPE . ' collection: ' . connect::COLLECTION);
|
} else throw new exception('Failed to initialize ' . connect::TYPE . ' collection: ' . connect::COLLECTION);
|
||||||
} else throw new exception('Failed to initialize ' . static::TYPE . ' collection: ' . static::COLLECTION);
|
} else throw new exception('Failed to initialize ' . static::TYPE . ' collection: ' . static::COLLECTION);
|
||||||
} catch (exception $e) {
|
} catch (exception $$e) {
|
||||||
// Writing to the registry of errors
|
// Writing to the registry of errors
|
||||||
$errors[] = [
|
$$errors[] = [
|
||||||
'text' => $e->getMessage(),
|
'text' => $$e->getMessage(),
|
||||||
'file' => $e->getFile(),
|
'file' => $$e->getFile(),
|
||||||
'line' => $e->getLine(),
|
'line' => $$e->getLine(),
|
||||||
'stack' => $e->getTrace()
|
'stack' => $$e->getTrace()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,15 +130,15 @@ trait document
|
||||||
*
|
*
|
||||||
* Write a property into an instance of the ArangoDB document
|
* Write a property into an instance of the ArangoDB document
|
||||||
*
|
*
|
||||||
* @param string $name Name of the property
|
* @param string $$name Name of the property
|
||||||
* @param mixed $value Content of the property
|
* @param mixed $$value Content of the property
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __set(string $name, mixed $value = null): void
|
public function __set(string $$name, mixed $$value = null): void
|
||||||
{
|
{
|
||||||
// Writing to the property into an instance of the ArangoDB document and exit (success)
|
// Writing to the property into an instance of the ArangoDB document and exit (success)
|
||||||
$this->document->{$name} = $value;
|
$$this->document->{$$name} = $$value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -146,15 +146,15 @@ trait document
|
||||||
*
|
*
|
||||||
* Read a property from an instance of the ArangoDB docuemnt
|
* Read a property from an instance of the ArangoDB docuemnt
|
||||||
*
|
*
|
||||||
* @param string $name Name of the property
|
* @param string $$name Name of the property
|
||||||
*
|
*
|
||||||
* @return mixed Content of the property
|
* @return mixed Content of the property
|
||||||
*/
|
*/
|
||||||
public function __get(string $name): mixed
|
public function __get(string $$name): mixed
|
||||||
{
|
{
|
||||||
// Read a property from an instance of the ArangoDB document and exit (success)
|
// Read a property from an instance of the ArangoDB document and exit (success)
|
||||||
return match ($name) {
|
return match ($$name) {
|
||||||
default => $this->document->{$name}
|
default => $$this->document->{$$name}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,14 +163,14 @@ trait document
|
||||||
*
|
*
|
||||||
* Deinitialize the property in an instance of the ArangoDB document
|
* Deinitialize the property in an instance of the ArangoDB document
|
||||||
*
|
*
|
||||||
* @param string $name Name of the property
|
* @param string $$name Name of the property
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __unset(string $name): void
|
public function __unset(string $$name): void
|
||||||
{
|
{
|
||||||
// Delete the property in an instance of the ArangoDB document and exit (success)
|
// Delete the property in an instance of the ArangoDB document and exit (success)
|
||||||
unset($this->document->{$name});
|
unset($$this->document->{$$name});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -178,14 +178,14 @@ trait document
|
||||||
*
|
*
|
||||||
* Check of initialization of the property into an instance of the ArangoDB document
|
* Check of initialization of the property into an instance of the ArangoDB document
|
||||||
*
|
*
|
||||||
* @param string $name Name of the property
|
* @param string $$name Name of the property
|
||||||
*
|
*
|
||||||
* @return bool The property is initialized?
|
* @return bool The property is initialized?
|
||||||
*/
|
*/
|
||||||
public function __isset(string $name): bool
|
public function __isset(string $$name): bool
|
||||||
{
|
{
|
||||||
// Check of initializatio nof the property and exit (success)
|
// Check of initializatio nof the property and exit (success)
|
||||||
return isset($this->document->{$name});
|
return isset($$this->document->{$$name});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -193,14 +193,14 @@ trait document
|
||||||
*
|
*
|
||||||
* Execute a method from an instance of the ArangoDB document
|
* Execute a method from an instance of the ArangoDB document
|
||||||
*
|
*
|
||||||
* @param string $name Name of the method
|
* @param string $$name Name of the method
|
||||||
* @param array $arguments Arguments for the method
|
* @param array $$arguments Arguments for the method
|
||||||
*
|
*
|
||||||
* @return mixed Result of execution of the method
|
* @return mixed Result of execution of the method
|
||||||
*/
|
*/
|
||||||
public function __call(string $name, array $arguments = []): mixed
|
public function __call(string $$name, array $$arguments = []): mixed
|
||||||
{
|
{
|
||||||
// Execute the method and exit (success)
|
// Execute the method and exit (success)
|
||||||
return method_exists($this->document, $name) ? $this->document->{$name}($arguments) ?? null : null;
|
return method_exists($$this->document, $$name) ? $$this->document->{$$name}($$arguments) ?? null : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ use exception;
|
||||||
*
|
*
|
||||||
* Trait with files handlers
|
* Trait with files handlers
|
||||||
*
|
*
|
||||||
* @method static void delete(string $directory, array &$errors)
|
* @method static void delete(string $$directory, array &$$errors)
|
||||||
*
|
*
|
||||||
* @package ${REPO_OWNER}\${REPO_NAME}\models\traits
|
* @package ${REPO_OWNER}\${REPO_NAME}\models\traits
|
||||||
*
|
*
|
||||||
|
@ -26,37 +26,37 @@ trait files
|
||||||
*
|
*
|
||||||
* Delete files recursively
|
* Delete files recursively
|
||||||
*
|
*
|
||||||
* @param string $directory Directory
|
* @param string $$directory Directory
|
||||||
* @param array &$errors Registry of errors
|
* @param array &$$errors Registry of errors
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function delete(string $directory, array &$errors = []): void
|
private static function delete(string $$directory, array &$$errors = []): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (file_exists($directory)) {
|
if (file_exists($$directory)) {
|
||||||
// Directory exists
|
// Directory exists
|
||||||
|
|
||||||
// Deleting descendant files and directories (enter to the recursion)
|
// Deleting descendant files and directories (enter to the recursion)
|
||||||
foreach (scandir($directory) as $file) {
|
foreach (scandir($$directory) as $$file) {
|
||||||
if ($file === '.' || $file === '..') continue;
|
if ($$file === '.' || $$file === '..') continue;
|
||||||
else if (is_dir("$directory/$file")) static::delete("$directory/$file", $errors);
|
else if (is_dir("$$directory/$$file")) static::delete("$$directory/$$file", $$errors);
|
||||||
else unlink("$directory/$file");
|
else unlink("$$directory/$$file");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deleting the directory
|
// Deleting the directory
|
||||||
rmdir($directory);
|
rmdir($$directory);
|
||||||
|
|
||||||
// Exit (success)
|
// Exit (success)
|
||||||
return;
|
return;
|
||||||
} else throw new exception('Directory does not exist');
|
} else throw new exception('Directory does not exist');
|
||||||
} catch (exception $e) {
|
} catch (exception $$e) {
|
||||||
// Writing to the registry of errors
|
// Writing to the registry of errors
|
||||||
$errors[] = [
|
$$errors[] = [
|
||||||
'text' => $e->getMessage(),
|
'text' => $$e->getMessage(),
|
||||||
'file' => $e->getFile(),
|
'file' => $$e->getFile(),
|
||||||
'line' => $e->getLine(),
|
'line' => $$e->getLine(),
|
||||||
'stack' => $e->getTrace()
|
'stack' => $$e->getTrace()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ use exception;
|
||||||
* @uses document_trait
|
* @uses document_trait
|
||||||
* @uses document_interface
|
* @uses document_interface
|
||||||
*
|
*
|
||||||
* @method bool|null status(array &$errors) Check document by its status
|
* @method bool|null status(array &$$errors) Check document by its status
|
||||||
*
|
*
|
||||||
* @package ${REPO_OWNER}\${REPO_NAME}\models\traits
|
* @package ${REPO_OWNER}\${REPO_NAME}\models\traits
|
||||||
*
|
*
|
||||||
|
@ -33,22 +33,22 @@ trait status
|
||||||
*
|
*
|
||||||
* Check document by its status
|
* Check document by its status
|
||||||
*
|
*
|
||||||
* @param array &$errors Registry of errors
|
* @param array &$$errors Registry of errors
|
||||||
*
|
*
|
||||||
* @return ?bool Status, if found
|
* @return ?bool Status, if found
|
||||||
*/
|
*/
|
||||||
public function status(array &$errors = []): ?bool
|
public function status(array &$$errors = []): ?bool
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// Read from ArangoDB and exit (success)
|
// Read from ArangoDB and exit (success)
|
||||||
return $this->document->active ?? false;
|
return $$this->document->active ?? false;
|
||||||
} catch (exception $e) {
|
} catch (exception $$e) {
|
||||||
// Writing to the registry of errors
|
// Writing to the registry of errors
|
||||||
$errors[] = [
|
$$errors[] = [
|
||||||
'text' => $e->getMessage(),
|
'text' => $$e->getMessage(),
|
||||||
'file' => $e->getFile(),
|
'file' => $$e->getFile(),
|
||||||
'line' => $e->getLine(),
|
'line' => $$e->getLine(),
|
||||||
'stack' => $e->getTrace()
|
'stack' => $$e->getTrace()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,12 @@ define('ROOT', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'
|
||||||
// Initializing path to the directory of views
|
// Initializing path to the directory of views
|
||||||
define('VIEWS', realpath('..' . DIRECTORY_SEPARATOR . 'views'));
|
define('VIEWS', realpath('..' . DIRECTORY_SEPARATOR . 'views'));
|
||||||
|
|
||||||
|
// Initializing path to the directory of storage
|
||||||
|
define('STORAGE', realpath('..' . DIRECTORY_SEPARATOR . 'storage'));
|
||||||
|
|
||||||
|
// Initializing path to the directory of settings
|
||||||
|
define('SETTINGS', realpath('..' . DIRECTORY_SEPARATOR . 'settings'));
|
||||||
|
|
||||||
// Initializing path to the directory of the storage
|
// Initializing path to the directory of the storage
|
||||||
define('STORAGE', realpath('..' . DIRECTORY_SEPARATOR . 'storage'));
|
define('STORAGE', realpath('..' . DIRECTORY_SEPARATOR . 'storage'));
|
||||||
|
|
||||||
|
@ -32,12 +38,12 @@ define('THEME', 'default');
|
||||||
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||||
|
|
||||||
// Initializing core
|
// Initializing core
|
||||||
$core = new core(namespace: __NAMESPACE__);
|
$$core = new core(namespace: __NAMESPACE__);
|
||||||
|
|
||||||
// Initializing routes
|
// Initializing routes
|
||||||
$router->router
|
$$router->router
|
||||||
->write('/', new route('index', 'index'), 'GET')
|
->write('/', new route('index', 'index'), 'GET')
|
||||||
;
|
;
|
||||||
|
|
||||||
// Handling request
|
// Handling request
|
||||||
$core->start();
|
$$core->start();
|
||||||
|
|
|
@ -27,11 +27,11 @@ use ArrayAccess as array_access,
|
||||||
*
|
*
|
||||||
* @package ${REPO_OWNER}\${REPO_NAME}\views
|
* @package ${REPO_OWNER}\${REPO_NAME}\views
|
||||||
*
|
*
|
||||||
* @param twig $twig Instance of the twig templater
|
* @param twig $$twig Instance of the twig templater
|
||||||
* @param array $variables Registry of view global variables
|
* @param array $$variables Registry of view global variables
|
||||||
*
|
*
|
||||||
* @method void __construct(?session &$session) Constructor
|
* @method void __construct(?session &$$session) Constructor
|
||||||
* @method string|null render(string $file, ?array $variables) Render the HTML-document
|
* @method string|null render(string $$file, ?array $$variables) Render the HTML-document
|
||||||
*
|
*
|
||||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||||
* @author ${REPO_OWNER} <mail@domain.zone>
|
* @author ${REPO_OWNER} <mail@domain.zone>
|
||||||
|
@ -41,35 +41,35 @@ final class templater extends controller implements array_access
|
||||||
/**
|
/**
|
||||||
* Twig
|
* Twig
|
||||||
*
|
*
|
||||||
* @var twig $twig Instance of the twig templater
|
* @var twig $$twig Instance of the twig templater
|
||||||
*/
|
*/
|
||||||
readonly public twig $twig;
|
readonly public twig $$twig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Variables
|
* Variables
|
||||||
*
|
*
|
||||||
* @var array $variables Registry of view global variables
|
* @var array $$variables Registry of view global variables
|
||||||
*/
|
*/
|
||||||
public array $variables = [];
|
public array $$variables = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor of an instance
|
* Constructor of an instance
|
||||||
*
|
*
|
||||||
* @param ?session $session Instance of the session in ArangoDB
|
* @param ?session $$session Instance of the session in ArangoDB
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(?session &$session = null)
|
public function __construct(?session &$$session = null)
|
||||||
{
|
{
|
||||||
// Initializing the Twig instance
|
// Initializing the Twig instance
|
||||||
$this->twig = new twig(new FilesystemLoader(VIEWS));
|
$$this->twig = new twig(new FilesystemLoader(VIEWS));
|
||||||
|
|
||||||
// Initializing global variables
|
// Initializing global variables
|
||||||
$this->twig->addGlobal('theme', 'default');
|
$$this->twig->addGlobal('theme', 'default');
|
||||||
$this->twig->addGlobal('server', $_SERVER);
|
$$this->twig->addGlobal('server', $$_SERVER);
|
||||||
$this->twig->addGlobal('cookies', $_COOKIE);
|
$$this->twig->addGlobal('cookies', $$_COOKIE);
|
||||||
if (!empty($session->status())) $this->twig->addGlobal('session', $session);
|
if (!empty($$session->status())) $$this->twig->addGlobal('session', $$session);
|
||||||
$this->twig->addGlobal('language', $language = $session?->buffer['language'] ?? language::en);
|
$$this->twig->addGlobal('language', $$language = $$session?->buffer['language'] ?? language::en);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,15 +77,15 @@ final class templater extends controller implements array_access
|
||||||
*
|
*
|
||||||
* Render the HTML-document
|
* Render the HTML-document
|
||||||
*
|
*
|
||||||
* @param string $file Related path to a HTML-document
|
* @param string $$file Related path to a HTML-document
|
||||||
* @param ?array $variables Registry of variables to push into registry of global variables
|
* @param ?array $$variables Registry of variables to push into registry of global variables
|
||||||
*
|
*
|
||||||
* @return ?string HTML-document
|
* @return ?string HTML-document
|
||||||
*/
|
*/
|
||||||
public function render(string $file, ?array $variables = null): ?string
|
public function render(string $$file, ?array $$variables = null): ?string
|
||||||
{
|
{
|
||||||
// Generation and exit (success)
|
// Generation and exit (success)
|
||||||
return $this->twig->render('themes' . DIRECTORY_SEPARATOR . $this->twig->getGlobal('theme') . DIRECTORY_SEPARATOR . $file, $variables + $this->variables);
|
return $$this->twig->render('themes' . DIRECTORY_SEPARATOR . $$this->twig->getGlobal('theme') . DIRECTORY_SEPARATOR . $$file, $$variables + $$this->variables);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,15 +93,15 @@ final class templater extends controller implements array_access
|
||||||
*
|
*
|
||||||
* Write the variable into the registry of the view global variables
|
* Write the variable into the registry of the view global variables
|
||||||
*
|
*
|
||||||
* @param string $name Name of the variable
|
* @param string $$name Name of the variable
|
||||||
* @param mixed $value Value of the variable
|
* @param mixed $$value Value of the variable
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __set(string $name, mixed $value = null): void
|
public function __set(string $$name, mixed $$value = null): void
|
||||||
{
|
{
|
||||||
// Write the variable and exit (success)
|
// Write the variable and exit (success)
|
||||||
$this->variables[$name] = $value;
|
$$this->variables[$$name] = $$value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,14 +109,14 @@ final class templater extends controller implements array_access
|
||||||
*
|
*
|
||||||
* Read the variable from the registry of the view global variables
|
* Read the variable from the registry of the view global variables
|
||||||
*
|
*
|
||||||
* @param string $name Name of the variable
|
* @param string $$name Name of the variable
|
||||||
*
|
*
|
||||||
* @return mixed Content of the variable, if they are found
|
* @return mixed Content of the variable, if they are found
|
||||||
*/
|
*/
|
||||||
public function __get(string $name): mixed
|
public function __get(string $$name): mixed
|
||||||
{
|
{
|
||||||
// Read the variable and exit (success)
|
// Read the variable and exit (success)
|
||||||
return $this->variables[$name];
|
return $$this->variables[$$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,14 +124,14 @@ final class templater extends controller implements array_access
|
||||||
*
|
*
|
||||||
* Delete the variable from the registry of the view global variables
|
* Delete the variable from the registry of the view global variables
|
||||||
*
|
*
|
||||||
* @param string $name Name of the variable
|
* @param string $$name Name of the variable
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __unset(string $name): void
|
public function __unset(string $$name): void
|
||||||
{
|
{
|
||||||
// Delete the variable and exit (success)
|
// Delete the variable and exit (success)
|
||||||
unset($this->variables[$name]);
|
unset($$this->variables[$$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,14 +139,14 @@ final class templater extends controller implements array_access
|
||||||
*
|
*
|
||||||
* Check of initialization in the registry of the view global variables
|
* Check of initialization in the registry of the view global variables
|
||||||
*
|
*
|
||||||
* @param string $name Name of the variable
|
* @param string $$name Name of the variable
|
||||||
*
|
*
|
||||||
* @return bool The variable is initialized?
|
* @return bool The variable is initialized?
|
||||||
*/
|
*/
|
||||||
public function __isset(string $name): bool
|
public function __isset(string $$name): bool
|
||||||
{
|
{
|
||||||
// Check of initialization of the variable and exit (success)
|
// Check of initialization of the variable and exit (success)
|
||||||
return isset($this->variables[$name]);
|
return isset($$this->variables[$$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -154,15 +154,15 @@ final class templater extends controller implements array_access
|
||||||
*
|
*
|
||||||
* Write the variable into the registry of the view global variables
|
* Write the variable into the registry of the view global variables
|
||||||
*
|
*
|
||||||
* @param mixed $name Name of an offset of the variable
|
* @param mixed $$name Name of an offset of the variable
|
||||||
* @param mixed $value Value of the variable
|
* @param mixed $$value Value of the variable
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function offsetSet(mixed $name, mixed $value): void
|
public function offsetSet(mixed $$name, mixed $$value): void
|
||||||
{
|
{
|
||||||
// Write the variable and exit (success)
|
// Write the variable and exit (success)
|
||||||
$this->variables[$name] = $value;
|
$$this->variables[$$name] = $$value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,14 +170,14 @@ final class templater extends controller implements array_access
|
||||||
*
|
*
|
||||||
* Read the variable from the registry of the view global variables
|
* Read the variable from the registry of the view global variables
|
||||||
*
|
*
|
||||||
* @param mixed $name Name of the variable
|
* @param mixed $$name Name of the variable
|
||||||
*
|
*
|
||||||
* @return mixed Content of the variable, if they are found
|
* @return mixed Content of the variable, if they are found
|
||||||
*/
|
*/
|
||||||
public function offsetGet(mixed $name): mixed
|
public function offsetGet(mixed $$name): mixed
|
||||||
{
|
{
|
||||||
// Read the variable and exit (success)
|
// Read the variable and exit (success)
|
||||||
return $this->variables[$name];
|
return $$this->variables[$$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -185,14 +185,14 @@ final class templater extends controller implements array_access
|
||||||
*
|
*
|
||||||
* Delete the variable from the registry of the view global variables
|
* Delete the variable from the registry of the view global variables
|
||||||
*
|
*
|
||||||
* @param mixed $name Name of the variable
|
* @param mixed $$name Name of the variable
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function offsetUnset(mixed $name): void
|
public function offsetUnset(mixed $$name): void
|
||||||
{
|
{
|
||||||
// Delete the variable and exit (success)
|
// Delete the variable and exit (success)
|
||||||
unset($this->variables[$name]);
|
unset($$this->variables[$$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -200,14 +200,14 @@ final class templater extends controller implements array_access
|
||||||
*
|
*
|
||||||
* Check of initialization in the registry of the view global variables
|
* Check of initialization in the registry of the view global variables
|
||||||
*
|
*
|
||||||
* @param mixed $name Name of the variable
|
* @param mixed $$name Name of the variable
|
||||||
*
|
*
|
||||||
* @return bool The variable is initialized?
|
* @return bool The variable is initialized?
|
||||||
*/
|
*/
|
||||||
public function offsetExists(mixed $name): bool
|
public function offsetExists(mixed $$name): bool
|
||||||
{
|
{
|
||||||
// Check of initialization of the variable and exit (success)
|
// Check of initialization of the variable and exit (success)
|
||||||
return isset($this->variables[$name]);
|
return isset($$this->variables[$$name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue