Skip to content

Commit

Permalink
Merge pull request #525 from portabilis/2.2
Browse files Browse the repository at this point in the history
[2.2] Upgrade - Work in progress
  • Loading branch information
edersoares authored Jul 29, 2019
2 parents e617f0a + fa9657f commit 5affcc3
Show file tree
Hide file tree
Showing 1,486 changed files with 67,827 additions and 169,426 deletions.
2 changes: 0 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ APP_DEFAULT_HOST=ieducar.com.br
API_ACCESS_KEY=
API_SECRET_KEY=

CORE_EXT_CONFIGURATION_ENV="${APP_ENV}"

LEGACY_CODE=true
LEGACY_DISPLAY_ERRORS=false
LEGACY_PATH=ieducar
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ ieducar-*.tar.gz
.env.testing
.php_cs.cache
docker-compose.override.yml
phinx.php
phinx.yml

/node_modules
/public/hot
Expand Down Expand Up @@ -45,7 +43,6 @@ yarn-error.log
/deploy
Vagrantfile
deploy/.ruby-version
ieducar/configuration/ieducar.ini
ieducar/modules/Reports
ieducar/intranet/filaunica
ieducar/intranet/reservavaga
Expand Down
76 changes: 76 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,68 @@ matrix:

- language: php

php:
- '7.1'

sudo: required

dist: xenial

addons:
postgresql: '9.5'
chrome: stable

cache:
directories:
- $HOME/.composer/cache

before_script:
- composer new-install
- php artisan dusk:chrome-driver 74
- php artisan serve > /dev/null 2>&1 &

script:
- vendor/bin/phpunit
- php artisan dusk

env:
- APP_URL=http://localhost:8000
- APP_ENV=testing
- DB_CONNECTION=pgsql
- DB_HOST=localhost
- DB_PORT=5432
- DB_DATABASE=travis
- DB_USERNAME=postgres
- DB_PASSWORD=
- API_ACCESS_KEY=ieducar-access-key
- API_SECRET_KEY=ieducar-secret-key

- language: php

php:
- '7.2'

sudo: required

dist: xenial

addons:
postgresql: '9.5'
chrome: stable

cache:
directories:
- $HOME/.composer/cache

before_script:
- composer new-install
- php artisan dusk:chrome-driver 74
- php artisan serve > /dev/null 2>&1 &

script:
- vendor/bin/phpunit
- php artisan dusk

env:
- APP_URL=http://localhost:8000
- APP_ENV=testing
Expand All @@ -27,6 +78,19 @@ matrix:
- API_ACCESS_KEY=ieducar-access-key
- API_SECRET_KEY=ieducar-secret-key

- language: php

php:
- '7.3'

sudo: required

dist: xenial

addons:
postgresql: '9.5'
chrome: stable

cache:
directories:
- $HOME/.composer/cache
Expand All @@ -39,3 +103,15 @@ matrix:
script:
- vendor/bin/phpunit
- php artisan dusk

env:
- APP_URL=http://localhost:8000
- APP_ENV=testing
- DB_CONNECTION=pgsql
- DB_HOST=localhost
- DB_PORT=5432
- DB_DATABASE=travis
- DB_USERNAME=postgres
- DB_PASSWORD=
- API_ACCESS_KEY=ieducar-access-key
- API_SECRET_KEY=ieducar-secret-key
11 changes: 8 additions & 3 deletions app/Console/Commands/DatabaseRestoreCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Str;

class DatabaseRestoreCommand extends Command
{
Expand Down Expand Up @@ -89,11 +90,15 @@ private function createDatabaseList($filename)
*/
private function removeTableDataFromDatabaseList(array $tables)
{
$definition = 'sed -i \'/TABLE DATA %s/d\' %s';

if (Str::contains(PHP_OS, 'Darwin')) {
$definition = 'sed -i \'\' \'/TABLE DATA %s/d\' %s';
}

foreach ($tables as $table) {
$table = str_replace('.', ' ', $table);

$definition = 'sed -i \'/TABLE DATA %s/d\' %s';

$command = sprintf(
$definition,
$table,
Expand Down Expand Up @@ -177,7 +182,7 @@ private function restoreDatabaseUsingBackupFile($database, $filename)
*/
private function alterSearchPathInDatabase($database)
{
$definition = 'echo "ALTER DATABASE %s SET search_path = \"\$user\", public, portal, cadastro, acesso, alimentos, consistenciacao, historico, pmiacoes, pmicontrolesis, pmidrh, pmieducar, pmiotopic, urbano, modules;" | psql -h %s -p %s -U %s';
$definition = 'echo "ALTER DATABASE %s SET search_path = \"\$user\", public, portal, cadastro, historico, pmieducar, urbano, modules;" | psql -h %s -p %s -U %s';

$command = sprintf(
$definition,
Expand Down
37 changes: 0 additions & 37 deletions app/Console/Commands/LegacyDatabaseCommand.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/Console/Commands/LegacyMakeTestsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private function getRoutesFromFile()
*/
private function getRoutesFromDatabase()
{
$result = DB::select("SELECT arquivo FROM portal.menu_submenu WHERE arquivo <> ''");
$result = DB::select("SELECT link FROM menus WHERE link <> ''");

return array_map(function ($value) {
return $value->arquivo;
Expand Down
71 changes: 0 additions & 71 deletions app/Console/Commands/ReportsInstallCommand.php

This file was deleted.

42 changes: 11 additions & 31 deletions app/Http/Controllers/LegacyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ private function getLegacyPath()
return base_path(config('legacy.path'));
}

/**
* Return i-Educar original bootstrap file.
*
* @return string
*/
private function getLegacyBootstrapFile()
{
return $this->getLegacyPath() . '/includes/bootstrap.php';
}

/**
* Define which errors and exceptions are shown.
*
Expand All @@ -69,26 +59,6 @@ private function configureErrorsAndExceptions()
restore_exception_handler();
}

/**
* Load bootstrap file, if not found, throw a HttpException with HTTP error
* code 500 Server Internal Error.
*
* @return void
*
* @throws HttpException
* @throws Exception
*/
private function loadLegacyBootstrapFile()
{
$filename = $this->getLegacyBootstrapFile();

if (false === file_exists($filename)) {
throw new HttpException(500, 'Legacy bootstrap file not found.');
}

$this->loadFileOrAbort($filename);
}

/**
* Load legacy route file, if not found, throw a HttpException with HTTP
* error code 404 Not Found.
Expand Down Expand Up @@ -195,6 +165,16 @@ private function getHttpStatusCode()
return http_response_code() ?: Response::HTTP_OK;
}

/**
* Change directory.
*
* @return void
*/
private function changeDirectory()
{
chdir(base_path('ieducar/intranet'));
}

/**
* Start session, configure errors and exceptions and load necessary files
* to run legacy code.
Expand All @@ -212,7 +192,7 @@ private function requireFileFromLegacy($filename)

$this->overrideGlobals();
$this->configureErrorsAndExceptions();
$this->loadLegacyBootstrapFile();
$this->changeDirectory();
$this->loadLegacyFile($filename);

$content = ob_get_contents();
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Kernel extends HttpKernel
\App\Http\Middleware\ChangeAppName::class,
\App\Http\Middleware\ConnectTenantDatabase::class,
\App\Http\Middleware\SetLayoutVariables::class,
\App\Http\Middleware\LoadLegacyConfig::class,
\App\Http\Middleware\LoadSettings::class,
],

'api' => [
Expand Down Expand Up @@ -81,7 +81,7 @@ class Kernel extends HttpKernel
*/
protected $middlewarePriority = [
\App\Http\Middleware\ConnectTenantDatabase::class,
\App\Http\Middleware\LoadLegacyConfig::class,
\App\Http\Middleware\LoadSettings::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\Authenticate::class,
Expand Down
Loading

0 comments on commit 5affcc3

Please sign in to comment.