Skip to content

Commit

Permalink
Merge pull request ProcessMaker#4479 from ProcessMaker/refactor/FOUR-…
Browse files Browse the repository at this point in the history
…6601

FOUR-6601: Refactor settings
  • Loading branch information
ryancooley authored Sep 2, 2022
2 parents b00af04 + 4516d70 commit a85ad49
Show file tree
Hide file tree
Showing 20 changed files with 1,454 additions and 965 deletions.
44 changes: 32 additions & 12 deletions ProcessMaker/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,60 @@

use Igaster\LaravelTheme\Facades\Theme;
use Illuminate\Foundation\Application as IlluminateApplication;
use Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables;
use Illuminate\Support\Facades\Auth;
use ProcessMaker\Models\Setting;
use ProcessMaker\Providers\SettingServiceProvider;

/**
* Class Application
* Class Application.
*/
class Application extends IlluminateApplication
{
// Our ProcessMaker Version
const VERSION = '4.0.0';
// ProcessMaker Version
public const VERSION = '4.0.0';

public function __construct($basePath = null)
{
parent::__construct($basePath);

$this->afterBootstrapping(LoadEnvironmentVariables::class, function () {
$this->register(SettingServiceProvider::class);
});
}

/**
* Sets the timezone for the application and for php with the specified timezone
* @param $tz string The timezone to set to
* Sets the timezone for the application and for php with the specified timezone.
*
* @param $timezone string
*/
public function setTimezone($tz)
public function setTimezone(string $timezone): void
{
config(['app.timezone' => $tz]);
if (!$this->configurationIsCached()) {
config(['app.timezone' => $timezone]);
}

date_default_timezone_set(config('app.timezone'));
}

/**
* Retrieves the currently set timezone
* @return string The timezone for the system
* Retrieves the currently set timezone.
*/
public function getTimezone()
public function getTimezone(): string
{
return config('app.timezone');
}

/**
* TODO Is this method, getSystemConstants() still necessary?
*
* Return the System defined constants and Application variables
* Constants: SYS_*
* Sessions : USER_* , URS_*
*
* @note: This is ported from Gulliver System. This will most likely need to be refactored/removed
* @return array Contents of system contents.
*
* @return array contents of system contents
*/
public function getSystemConstants()
{
Expand All @@ -65,7 +83,9 @@ public function getSystemConstants()
* Get the path to the application "app" directory.
*
* @note This extends the base Application to specify ProcessMaker instead of app as the main directory
* @param string $path Optionally, a path to append to the app path
*
* @param string $path Optionally, a path to append to the app path
*
* @return string
*/
public function path($path = '')
Expand Down
4 changes: 2 additions & 2 deletions ProcessMaker/Console/Commands/IndexedSearchEnable.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ private function setConfig($driver, $url = null, $prefix = null)

Storage::disk('install')->put('.env', $env);

$this->callSilent('config:cache');

config([
'scout.driver' => $driver,
'scout.prefix' => $prefix,
'scout.queue' => false,
'elastic.client.hosts' => [$url],
]);

refresh_artisan_caches();
}

private function retrieveOptions()
Expand Down
18 changes: 15 additions & 3 deletions ProcessMaker/Console/Commands/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Database\Query\Grammars\SqlServerGrammar;
use Illuminate\Encryption\Encrypter;
use Illuminate\Support\Facades\DB;
Expand Down Expand Up @@ -265,9 +266,20 @@ public function handle()
// Now store the env file
Storage::disk('install')->put('.env', $contents);

$this->call('config:cache');
$this->call('config:clear');
$this->call('cache:clear');
$this->call('config:cache', [
'--no-interaction' => true,
'--quiet' => true,
]);

$this->call('config:clear', [
'--no-interaction' => true,
'--quiet' => true,
]);

$this->call('cache:clear', [
'--no-interaction' => true,
'--quiet' => true,
]);

// Set username, email, password
$this->fetchUserInformation();
Expand Down
28 changes: 28 additions & 0 deletions ProcessMaker/Events/SettingsLoaded.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace ProcessMaker\Events;

use Illuminate\Contracts\Config\Repository;
use Illuminate\Foundation\Events\Dispatchable;

class SettingsLoaded
{
use Dispatchable;

/**
* @implements Illuminate\Contracts\Config\Repository::class
*/
public $configuration;

/**
* Create a new event instance.
*
* @param \Illuminate\Contracts\Config\Repository $configuration
*
* @return void
*/
public function __construct(Repository $configuration)
{
$this->configuration = &$configuration;
}
}
106 changes: 0 additions & 106 deletions ProcessMaker/Helper/helper.php

This file was deleted.

125 changes: 0 additions & 125 deletions ProcessMaker/Helpers/SettingsHelper.php

This file was deleted.

Loading

0 comments on commit a85ad49

Please sign in to comment.