Skip to content

Commit

Permalink
Add Laravel 6 support
Browse files Browse the repository at this point in the history
Remove unnecessary logging classes

Update hashing

Fix seeding

Replace Event:fire with Event:dispatch

Modify TTL to seconds

Replace dotenv constructor with static create method

Add SECONDS_PER_WEEK and SECONDS_PER_MONTH constants
  • Loading branch information
taras committed Oct 23, 2019
1 parent 880b4c6 commit ae6b028
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 62 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"prefer-stable": true,
"require": {
"php": ">=7.0.0",
"barryvdh/laravel-cors": "~0.10.0",
"barryvdh/laravel-cors": "~0.11.0",
"doctrine/dbal": "~2.5.0",
"guzzlehttp/guzzle": "~6.0",
"symfony/yaml": "~2.8|~3.0",
Expand Down
6 changes: 3 additions & 3 deletions config/df.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@
],
'query_log_enabled' => env('DB_QUERY_LOG_ENABLED', false),
],
// Cache config, in minutes
'default_cache_ttl' => env('CACHE_DEFAULT_TTL', env('DF_CACHE_TTL', 300)),
// Cache config, in seconds
'default_cache_ttl' => env('CACHE_DEFAULT_TTL', env('DF_CACHE_TTL', 18000)),
// Session config
'allow_forever_sessions' => env('DF_ALLOW_FOREVER_SESSIONS', false),
// System URLs
'confirm_reset_url' => env('DF_CONFIRM_RESET_URL', '/dreamfactory/dist/#/reset-password'),
'confirm_invite_url' => env('DF_CONFIRM_INVITE_URL', '/dreamfactory/dist/#/user-invite'),
'confirm_register_url' => env('DF_CONFIRM_REGISTER_URL', '/dreamfactory/dist/#/register-confirm'),
'confirm_code_length' => env('DF_CONFIRM_CODE_LENGTH', 32),
'confirm_code_ttl' => env('DF_CONFIRM_CODE_TTL', 1440), // 1440 minutes (24 hours).
'confirm_code_ttl' => env('DF_CONFIRM_CODE_TTL', 86400), // 86400 seconds (24 hours).
'landing_page' => env('DF_LANDING_PAGE', '/dreamfactory/dist/index.html'),
// Enable/disable detailed CORS logging
'log_cors_info' => false,
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/ClearAllFileCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public function __construct()
*/
public function handle()
{
$this->laravel['events']->fire('cache:clearing', ['file']);
$this->laravel['events']->dispatch('cache:clearing', ['file']);
$this->removeDirectory($this->cacheRoot);
$this->laravel['events']->fire('cache:cleared', ['file']);
$this->laravel['events']->dispatch('cache:cleared', ['file']);
$this->info('Cleared DreamFactory cache for all instances!');
}

Expand Down
6 changes: 3 additions & 3 deletions src/Components/RestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ protected function firePreProcessEvent($name = null, $resource = null)
}
$event = new PreProcessApiEvent($name, $this->request, $this->response, $resource);
/** @noinspection PhpUnusedLocalVariableInspection */
$results = \Event::fire($event);
$results = \Event::dispatch($event);
$this->response = $event->response;
}

Expand Down Expand Up @@ -363,7 +363,7 @@ protected function firePostProcessEvent($name = null, $resource = null)
$resource = $this->getEventResource();
}
/** @noinspection PhpUnusedLocalVariableInspection */
$results = \Event::fire(new PostProcessApiEvent($name, $this->request, $this->response, $resource));
$results = \Event::dispatch(new PostProcessApiEvent($name, $this->request, $this->response, $resource));
}

/**
Expand All @@ -388,7 +388,7 @@ protected function fireFinalEvent($name = null, $resource = null)
$resource = $this->getEventResource();
}
/** @noinspection PhpUnusedLocalVariableInspection */
$results = \Event::fire(new ApiEvent($name, $this->request, $this->response, $resource));
$results = \Event::dispatch(new ApiEvent($name, $this->request, $this->response, $resource));
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/Enums/DateTimeIntervals.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ class DateTimeIntervals extends FactoryEnum
* @var int
*/
const SECONDS_PER_DAY = 86400;
/**
* @var int
*/
const SECONDS_PER_WEEK = 604800;
/**
* @var int
*/
const SECONDS_PER_MONTH = 18144000;
/**
* @var int Stupid, I know, but at least it's a constant
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Handlers/Events/ServiceEventHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function handleApiEvent($event)
Log::debug('Service event handled: ' . $eventName);
/** @var BaseRestService $service */
$service = \ServiceManager::getServiceById($record->service_id);
Event::fire(new ServiceAssignedEvent($service, $event, $record->toArray()));
Event::dispatch(new ServiceAssignedEvent($service, $event, $record->toArray()));
}
}

Expand Down
17 changes: 0 additions & 17 deletions src/LogHandlers/DfLoggingTrait.php

This file was deleted.

8 changes: 0 additions & 8 deletions src/LogHandlers/ErrorLogHandler.php

This file was deleted.

8 changes: 0 additions & 8 deletions src/LogHandlers/RotatingFileHandler.php

This file was deleted.

7 changes: 0 additions & 7 deletions src/LogHandlers/StreamHandler.php

This file was deleted.

8 changes: 0 additions & 8 deletions src/LogHandlers/SyslogHandler.php

This file was deleted.

2 changes: 2 additions & 0 deletions src/Models/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ public function getLaunchUrlAttribute()

public static function boot()
{
parent::boot();

static::saved(
function (App $app){
if (!$app->is_active) {
Expand Down
2 changes: 1 addition & 1 deletion src/Models/ServiceCacheConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected static function prepareConfigSchemaField(array &$schema)
' Only GET requests without payload are cached.';
break;
case 'cache_ttl':
$schema['label'] = 'Cache Time To Live (minutes)';
$schema['label'] = 'Cache Time To Live (seconds)';
$schema['description'] =
'The amount of time each cached response is allowed to last.' .
' Once expired, a new request to the service is made.';
Expand Down
5 changes: 3 additions & 2 deletions src/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Hash;
use Validator;

/**
Expand Down Expand Up @@ -475,7 +476,7 @@ public static function deleteInternal($id, $record, $params = [])
*/
public function setSecurityAnswerAttribute($value)
{
$this->attributes['security_answer'] = bcrypt($value);
$this->attributes['security_answer'] = Hash::make($value);
}

/**
Expand All @@ -486,7 +487,7 @@ public function setSecurityAnswerAttribute($value)
public function setPasswordAttribute($password)
{
if (!empty($password)) {
$password = bcrypt($password);
$password = Hash::make($password);
JWTUtilities::invalidateTokenByUserId($this->id);
// When password is set user account must be confirmed. Confirming user
// account here with confirm_code = null.
Expand Down
2 changes: 1 addition & 1 deletion src/Utility/FileUtilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ public static function updateEnvSetting(array $settings, $path = null)
* Using a new instance of dotenv to get the
* most update to .env file content for reading.
*/
$dotenv = new Dotenv(base_path());
$dotenv = Dotenv::create(base_path());
$dotenv->load();

$search = $key . '=' . getenv($key);
Expand Down

0 comments on commit ae6b028

Please sign in to comment.