diff --git a/composer.json b/composer.json index 9a34166d..250c8b35 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/webfiori/framework/cli/commands/CreateCommand.php b/webfiori/framework/cli/commands/CreateCommand.php index c9dc6026..888b55a5 100644 --- a/webfiori/framework/cli/commands/CreateCommand.php +++ b/webfiori/framework/cli/commands/CreateCommand.php @@ -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; @@ -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 { diff --git a/webfiori/framework/cli/commands/ListThemesCommand.php b/webfiori/framework/cli/commands/ListThemesCommand.php index c6e4ab57..53e42386 100644 --- a/webfiori/framework/cli/commands/ListThemesCommand.php +++ b/webfiori/framework/cli/commands/ListThemesCommand.php @@ -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; /** @@ -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.'); } /** diff --git a/webfiori/framework/cli/commands/RunSQLQueryCommand.php b/webfiori/framework/cli/commands/RunSQLQueryCommand.php index f0cf444b..55ec77a4 100644 --- a/webfiori/framework/cli/commands/RunSQLQueryCommand.php +++ b/webfiori/framework/cli/commands/RunSQLQueryCommand.php @@ -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; @@ -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.'); } /** diff --git a/webfiori/framework/cli/commands/SchedulerCommand.php b/webfiori/framework/cli/commands/SchedulerCommand.php index 121c9ef5..b8d5b6af 100644 --- a/webfiori/framework/cli/commands/SchedulerCommand.php +++ b/webfiori/framework/cli/commands/SchedulerCommand.php @@ -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; /** @@ -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') { diff --git a/webfiori/framework/cli/commands/UpdateSettingsCommand.php b/webfiori/framework/cli/commands/UpdateSettingsCommand.php index a014d33c..e6844bbc 100644 --- a/webfiori/framework/cli/commands/UpdateSettingsCommand.php +++ b/webfiori/framework/cli/commands/UpdateSettingsCommand.php @@ -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; @@ -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), diff --git a/webfiori/framework/cli/commands/UpdateTableCommand.php b/webfiori/framework/cli/commands/UpdateTableCommand.php index 8b483993..26c90c87 100644 --- a/webfiori/framework/cli/commands/UpdateTableCommand.php +++ b/webfiori/framework/cli/commands/UpdateTableCommand.php @@ -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; @@ -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.'); } /** diff --git a/webfiori/framework/session/Session.php b/webfiori/framework/session/Session.php index 91f70bc8..2b2b742c 100644 --- a/webfiori/framework/session/Session.php +++ b/webfiori/framework/session/Session.php @@ -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 = []; diff --git a/webfiori/framework/session/SessionOption.php b/webfiori/framework/session/SessionOption.php new file mode 100644 index 00000000..aea91495 --- /dev/null +++ b/webfiori/framework/session/SessionOption.php @@ -0,0 +1,39 @@ +pauseSessions(); if (!self::hasSession($sessionName)) { - $options['name'] = $sessionName; + $options[SessionOption::NAME] = $sessionName; $s = new Session($options); $s->start(); self::getInstance()->sessionsArr[] = $s;