Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fixTestsInLaravelRe…
Browse files Browse the repository at this point in the history
…lease
  • Loading branch information
vitormattos committed Dec 28, 2018
2 parents fd6a7ee + 342ad8d commit 7137390
Show file tree
Hide file tree
Showing 24 changed files with 239 additions and 736 deletions.
1 change: 0 additions & 1 deletion .env.example
Expand Up @@ -6,7 +6,6 @@ APP_URL=http://localhost
APP_TIMEZONE=America/Sao_Paulo
APP_TRACK_ERROR=false

API_URI=http://localhost/module/Api/Regra
API_ACCESS_KEY=
API_SECRET_KEY=

Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -14,6 +14,9 @@ matrix:
- DB_DATABASE=travis
- DB_USERNAME=postgres
- DB_PASSWORD=
- API_ACCESS_KEY=ieducar-access-key
- API_SECRET_KEY=ieducar-secret-key

cache:
directories:
- $HOME/.composer/cache
Expand Down
42 changes: 41 additions & 1 deletion app/Http/Controllers/LegacyController.php
Expand Up @@ -5,12 +5,28 @@
use Exception;
use Throwable;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class LegacyController extends Controller
{
/**
* @var Request
*/
private $request;

/**
* LegacyController constructor.
*
* @param Request $request
*/
public function __construct(Request $request)
{
$this->request = $request;
}

/**
* Return i-Educar legacy code path.
*
Expand Down Expand Up @@ -172,12 +188,15 @@ private function getHttpStatusCode()
* @param string $filename
*
* @return Response
*
* @throws Exception
*/
private function requireFileFromLegacy($filename)
{
ob_start();

$this->startLegacySession();
$this->overrideGlobals();
$this->configureErrorsAndExceptions();
$this->loadLegacyBootstrapFile();
$this->loadLegacyFile($filename);
Expand All @@ -198,7 +217,22 @@ private function requireFileFromLegacy($filename)
*/
private function startLegacySession()
{
session_start();
@session_start();
}

/**
* Override PHP Globals if not exists.
*
* @return void
*/
private function overrideGlobals()
{
$_SERVER['REQUEST_URI'] = $_SERVER['REQUEST_URI'] ?? $this->request->getRequestUri();

$_GET = empty($_GET) ? $this->request->query->all() : $_GET;
$_POST = empty($_POST) ? $this->request->request->all() : $_POST;
$_FILES = empty($_FILES) ? $this->request->files->all() : $_FILES;
$_COOKIE = empty($_COOKIE) ? $this->request->cookies->all() : $_COOKIE;
}

/**
Expand All @@ -207,6 +241,8 @@ private function startLegacySession()
* @param string $uri
*
* @return Response
*
* @throws Exception
*/
public function intranet($uri)
{
Expand All @@ -217,6 +253,8 @@ public function intranet($uri)
* Load module route file and generate a response.
*
* @return Response
*
* @throws Exception
*/
public function module()
{
Expand All @@ -229,6 +267,8 @@ public function module()
* @param string $uri
*
* @return Response
*
* @throws Exception
*/
public function modules($uri)
{
Expand Down
11 changes: 0 additions & 11 deletions bootstrap/testing.php

This file was deleted.

25 changes: 13 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ieducar/configuration/ieducar.ini.example
Expand Up @@ -112,8 +112,8 @@ app.recaptcha.options.lang = pt
app.recaptcha.options.theme = white

; Define chaves de acesso à API do i-Educar
apis.access_key =
apis.secret_key =
apis.access_key = ${API_ACCESS_KEY}
apis.secret_key = ${API_SECRET_KEY}
apis.educacao_token_header =
apis.educacao_token_key =

Expand Down
13 changes: 9 additions & 4 deletions ieducar/includes/bootstrap.php
@@ -1,5 +1,14 @@
<?php

use Illuminate\Foundation\Application;
use Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables;

$app = require_once __DIR__ . '/../../bootstrap/app.php';

if ($app instanceof Application) {
(new LoadEnvironmentVariables())->bootstrap($app);
}

if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
Expand All @@ -19,14 +28,10 @@
$configFile = PROJECT_ROOT . '/configuration/ieducar.ini';
}

$locale = CoreExt_Locale::getInstance();
$locale->setCulture('pt_BR')->setLocale();

global $coreExt;

$coreExt = [];
$coreExt['Config'] = new CoreExt_Config_Ini($configFile, CORE_EXT_CONFIGURATION_ENV);
$coreExt['Locale'] = $locale;

date_default_timezone_set($coreExt['Config']->app->locale->timezone);

Expand Down
10 changes: 5 additions & 5 deletions ieducar/intranet/include/clsCampos.inc.php
Expand Up @@ -1764,8 +1764,8 @@ classe = (classe == \'formmdtd\')? \'formlttd tr_\' + This.nome : \'formmdtd tr_

$retorno .= "<tr><td colspan='2' class='$classe'><span class='form'><b>$componente[3]</b></span>{$explicacao}</td></tr>\n";
} else {
if (isset($componente[10]) && ($componente[0] == 'textoDuploInv'
|| $componente[0] == 'textoInv')) {
if (!empty($componente[10]) && !empty($componente[0])
&& ($componente[0] == 'textoDuploInv' || $componente[0] == 'textoInv')) {
$name = " name='tr_{$componente[10]}' ";
} else {
$name = '';
Expand All @@ -1774,14 +1774,14 @@ classe = (classe == \'formmdtd\')? \'formlttd tr_\' + This.nome : \'formmdtd tr_
$style = (isset($componente['tr_invisivel']) && $componente['tr_invisivel']) ?
'style=\'visibility:collapse\'' : '';

$explicacao = ($componente[6]) ?
$explicacao = !empty($componente[6]) ?
"<br><sub style='vertical-align:top;'>{$componente[6]}</sub>" : '';

$retorno .= "<tr id='tr_$nome' {$name} $style><td class='$classe' valign='top'><span class='form'>$campo</span>{$obrigatorio}{$explicacao}</td><td class='$classe' valign='top'><span class='form'>\n";
}
} elseif ($tipo) {
if ($componente[10] == true) {
$explicacao = ($componente[6]) ?
if (!empty($componente[10]) && $componente[10] == true) {
$explicacao = !empty($componente[6]) ?
"<br><sub style='vertical-align:top;'>{$componente[6]}</sub>" : '';

$retorno .= "<span class='form'>$campo</span>{$explicacao}\n";
Expand Down
48 changes: 0 additions & 48 deletions ieducar/lib/CoreExt/DataMapper.php
Expand Up @@ -65,11 +65,6 @@ abstract class CoreExt_DataMapper
*/
protected $_tableSchema = '';

/**
* @var CoreExt_Locale
*/
protected $_locale = null;

/**
* Construtor.
*
Expand Down Expand Up @@ -504,16 +499,10 @@ public function findAll(array $columns = [], array $where = [], array $orderBy =
$columns['id'] = true;
}
}

// Reseta o locale para o default (en_US)
$this->getLocale()->resetLocale();
$this->_getDbAdapter()->Consulta($this->_getFindAllStatment($columns, $where, $orderBy));

$list = [];

// Retorna o locale para o usado no restante da aplicação
$this->getLocale()->setLocale();

while ($this->_getDbAdapter()->ProximoRegistro()) {
$list[] = $this->_createEntityObject($this->_getDbAdapter()->Tupla());
}
Expand Down Expand Up @@ -548,14 +537,9 @@ public function findAllUsingPreparedQuery(array $columns = [], array $where = []
}
}

// Reseta o locale para o default (en_US)
$this->getLocale()->resetLocale();

$sql = $this->_getFindAllStatment($columns, $where, $orderBy);

if ($this->_getDbAdapter()->execPreparedQuery($sql, $params) != false) {
// Retorna o locale para o usado no restante da aplicação
$this->getLocale()->setLocale();

while ($this->_getDbAdapter()->ProximoRegistro()) {
$list[] = $this->_createEntityObject($this->_getDbAdapter()->Tupla());
Expand Down Expand Up @@ -669,9 +653,6 @@ public function save(CoreExt_Entity $instance)
}

return $return;

// Retorna o locale para o usado no restante da aplicação
$this->getLocale()->setLocale();
}

/**
Expand Down Expand Up @@ -832,33 +813,4 @@ protected function _mapData($data, CoreExt_Entity $instance)

return $instance;
}

/**
* Setter.
*
* @param CoreExt_Locale $instance
*
* @return CoreExt_DataMapper Provê interface fluída
*/
public function setLocale(CoreExt_Locale $instance)
{
$this->_locale = $instance;

return $this;
}

/**
* Getter.
*
* @return CoreExt_Locale
*/
public function getLocale()
{
if (is_null($this->_locale)) {
require_once 'CoreExt/Locale.php';
$this->setLocale(CoreExt_Locale::getInstance());
}

return $this->_locale;
}
}

0 comments on commit 7137390

Please sign in to comment.