Skip to content

chore: Updated Core Libraries #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"webfiori/ui":"v2.6.1",
"webfiori/collections":"v1.1.4",
"webfiori/database":"v0.8.9",
"webfiori/cli":"v1.1.4",
"webfiori/mailer":"v1.1.3",
"webfiori/cli":"v1.2.0",
"webfiori/mailer":"v1.1.4",
"webfiori/err":"v1.0.9"
},
"require-dev": {
Expand Down
6 changes: 3 additions & 3 deletions webfiori/framework/cli/commands/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace webfiori\framework\cli\commands;

use webfiori\cli\CLICommand;
use webfiori\cli\CommandArgument;
use webfiori\cli\Argument;
use webfiori\framework\cli\CLIUtils;
use webfiori\framework\cli\helpers\ClassInfoReader;
use webfiori\framework\cli\helpers\CreateBackgroundTask;
Expand All @@ -33,8 +33,8 @@
class CreateCommand extends CLICommand {
public function __construct() {
parent::__construct('create', [
new CommandArgument('--c', 'What will be created. Possible values: table, entity, web-service, job, middleware, command, theme.', true),
new CommandArgument('--table', '', true),
new Argument('--c', 'What will be created. Possible values: table, entity, web-service, job, middleware, command, theme.', true),
new Argument('--table', '', true),
], 'Creates a system entity (middleware, web service, background process ...).');
}
public function createEntityFromQuery(): int {
Expand Down
4 changes: 2 additions & 2 deletions webfiori/framework/cli/commands/ListThemesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace webfiori\framework\cli\commands;

use webfiori\cli\CLICommand;
use webfiori\cli\CommandArgument;
use webfiori\cli\Argument;
use webfiori\framework\ThemeLoader;

/**
Expand All @@ -31,7 +31,7 @@ class ListThemesCommand extends CLICommand {
*/
public function __construct() {
parent::__construct('list-themes', [
new CommandArgument('--theme-name', 'An optional theme name. If provided, only given theme information will be shown.', true)
new Argument('--theme-name', 'An optional theme name. If provided, only given theme information will be shown.', true)
], 'List all registered themes.');
}
/**
Expand Down
16 changes: 8 additions & 8 deletions webfiori/framework/cli/commands/RunSQLQueryCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace webfiori\framework\cli\commands;

use webfiori\cli\CLICommand;
use webfiori\cli\CommandArgument;
use webfiori\cli\Argument;
use webfiori\database\Database;
use webfiori\database\DatabaseException;
use webfiori\database\Table;
Expand All @@ -30,13 +30,13 @@
class RunSQLQueryCommand extends CLICommand {
public function __construct() {
parent::__construct('run-query', [
new CommandArgument('--connection', 'Database connection that the query will be executed on.', true),
new CommandArgument('--schema', 'The namespace of a class that extends the class "webfiori\\framework\\DB" which represents database schema.', true),
new CommandArgument('--create', 'This option is used alongside the option --table and --schema. If it is provided, this means initiate the process of creating the database or the Table.', true),
new CommandArgument('--table', 'Table class to run query on.', true),
new CommandArgument('--file', 'The path to SQL file that holds SQL query.', true),
new CommandArgument('--no-confirm', 'If this argument is provided, the query will be executed without confirmation step.', true),
new CommandArgument('--show-sql', 'If this argument is provided, SQL statement will be shown in the console. This option is ignored if option --no-confirm is not provided.', true),
new Argument('--connection', 'Database connection that the query will be executed on.', true),
new Argument('--schema', 'The namespace of a class that extends the class "webfiori\\framework\\DB" which represents database schema.', true),
new Argument('--create', 'This option is used alongside the option --table and --schema. If it is provided, this means initiate the process of creating the database or the Table.', true),
new Argument('--table', 'Table class to run query on.', true),
new Argument('--file', 'The path to SQL file that holds SQL query.', true),
new Argument('--no-confirm', 'If this argument is provided, the query will be executed without confirmation step.', true),
new Argument('--show-sql', 'If this argument is provided, SQL statement will be shown in the console. This option is ignored if option --no-confirm is not provided.', true),
], 'Execute SQL query on specific database.');
}
/**
Expand Down
16 changes: 8 additions & 8 deletions webfiori/framework/cli/commands/SchedulerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace webfiori\framework\cli\commands;

use webfiori\cli\CLICommand;
use webfiori\cli\CommandArgument;
use webfiori\cli\Argument;
use webfiori\framework\scheduler\AbstractTask;
use webfiori\framework\scheduler\TasksManager;
/**
Expand Down Expand Up @@ -39,13 +39,13 @@ class SchedulerCommand extends CLICommand {
*/
public function __construct() {
parent::__construct('scheduler', [
new CommandArgument('p', 'Scheduler password. If it is set, then it must be provided here.', true),
new CommandArgument('--list', 'List all scheduled tasks.', true),
new CommandArgument('--check', 'Run a check against all tasks to check if it is time to execute them or not.', true),
new CommandArgument('--force', 'Force a specific task to execute.', true),
new CommandArgument('--task-name', 'The name of the task that will be forced to execute or to show its arguments.', true),
new CommandArgument('--show-task-args', 'If this one is provided with task name and a task has custom execution args, they will be shown.', true),
new CommandArgument('--show-log', 'If set, execution log will be shown after execution is completed.', true),
new Argument('p', 'Scheduler password. If it is set, then it must be provided here.', true),
new Argument('--list', 'List all scheduled tasks.', true),
new Argument('--check', 'Run a check against all tasks to check if it is time to execute them or not.', true),
new Argument('--force', 'Force a specific task to execute.', true),
new Argument('--task-name', 'The name of the task that will be forced to execute or to show its arguments.', true),
new Argument('--show-task-args', 'If this one is provided with task name and a task has custom execution args, they will be shown.', true),
new Argument('--show-log', 'If set, execution log will be shown after execution is completed.', true),
], 'Run tasks scheduler.');

if (TasksManager::getPassword() != 'NO_PASSWORD') {
Expand Down
4 changes: 2 additions & 2 deletions webfiori/framework/cli/commands/UpdateSettingsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use Throwable;
use webfiori\cli\CLICommand;
use webfiori\cli\CommandArgument;
use webfiori\cli\Argument;
use webfiori\cli\InputValidator;
use webfiori\framework\App;
use webfiori\framework\config\Controller;
Expand All @@ -29,7 +29,7 @@
class UpdateSettingsCommand extends CLICommand {
public function __construct() {
parent::__construct('update-settings', [
new CommandArgument('--w', 'An argument which is used to indicate what will be updated. '
new Argument('--w', 'An argument which is used to indicate what will be updated. '
.'Possible values are: version, app-name, scheduler-pass, page-title, '
.'page-description, primary-lang, title-sep, home-page, theme,'
.'admin-theme.', true),
Expand Down
4 changes: 2 additions & 2 deletions webfiori/framework/cli/commands/UpdateTableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace webfiori\framework\cli\commands;

use webfiori\cli\CLICommand;
use webfiori\cli\CommandArgument;
use webfiori\cli\Argument;
use webfiori\framework\cli\CLIUtils;
use webfiori\framework\cli\helpers\CreateTableObj;
use webfiori\framework\cli\helpers\TableObjHelper;
Expand All @@ -26,7 +26,7 @@ class UpdateTableCommand extends CLICommand {
*/
public function __construct() {
parent::__construct('update-table', [
new CommandArgument('--table', 'The namespace of the table class (including namespace).', true),
new Argument('--table', 'The namespace of the table class (including namespace).', true),
], 'Update a database table.');
}
/**
Expand Down
6 changes: 3 additions & 3 deletions webfiori/framework/session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,20 @@ public function __construct(array $options = []) {
$this->setIsRefresh(false);
}

if (!(isset($options['duration']) && $this->setDuration($options['duration']))) {
if (!(isset($options[SessionOption::DURATION]) && $this->setDuration($options[SessionOption::DURATION]))) {
$this->setDuration(self::DEFAULT_SESSION_DURATION);
}

if ($this->getDuration() == 0) {
$this->setIsRefresh(false);
}
$tempSName = isset($options['name']) ? trim($options['name']) : '';
$tempSName = isset($options[SessionOption::NAME]) ? trim($options[SessionOption::NAME]) : '';

if (!$this->setNameHelper($tempSName)) {
throw new SessionException('Invalid session name: \''.$tempSName.'\'.');
}

$this->getCookie()->setValue(isset($options['session-id']) ? trim($options['session-id']) : self::generateSessionID($tempSName));
$this->getCookie()->setValue(isset($options[SessionOption::SESSION_ID]) ? trim($options[SessionOption::SESSION_ID]) : self::generateSessionID($tempSName));
$this->resumedAt = 0;
$this->startedAt = 0;
$this->sessionVariables = [];
Expand Down
39 changes: 39 additions & 0 deletions webfiori/framework/session/SessionOption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2024 Ibrahim BinAlshikh
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
*
*/

namespace webfiori\framework\session;

/**
* A class which is used to hold the options names that are supported during
* new session initialization or session update.
*
* @author Ibrahim
*/
class SessionOption {
/**
* An option which is used to set session duration (minutes)
*/
const DURATION = 'duration';
/**
* An option which is used to set if session timeout will be refreshed on
* each request or not (bool)
*/
const REFRESH = 'refresh';
/**
* An option which is used to set the name of the session. The name will be
* same as session cookie.
*/
const NAME = 'name';
/**
* An option which is used to set the ID of the session.
*/
const SESSION_ID = 'session-id';
}
2 changes: 1 addition & 1 deletion webfiori/framework/session/SessionsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public static function start(string $sessionName, array $options = []) {
self::getInstance()->pauseSessions();

if (!self::hasSession($sessionName)) {
$options['name'] = $sessionName;
$options[SessionOption::NAME] = $sessionName;
$s = new Session($options);
$s->start();
self::getInstance()->sessionsArr[] = $s;
Expand Down