Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/command/PSFSConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace PSFS\command;

use PSFS\base\Router;
use Symfony\Component\Console\Application;
use Symfony\Component\Finder\Finder;

Expand All @@ -15,7 +14,6 @@

require_once $dir . 'autoload.php';


$project_path = $pwd . DIRECTORY_SEPARATOR . "src" . DIRECTORY_SEPARATOR;
if (file_exists($project_path . "bootstrap.php")) {
include_once($project_path . "bootstrap.php");
Expand All @@ -33,12 +31,16 @@
foreach ($commands as $com) if ($com->isFile()) include_once($com->getRealPath());

//Hidratamos con los comandos de los módulos
$domains = Router::getInstance()->getDomains();
$domains = \PSFS\base\Router::getInstance()->getDomains();
foreach ($domains as $domain => $paths) {
if (!preg_match('/ROOT/i', $domain)) {
if ((false === stripos($domain, "ROOT")) && file_exists($paths['base'])) {
$commands = new Finder();
$commands->in($paths['base'])->path("Command")->name("*.php");
foreach ($commands as $com) include_once($com->getRealPath());
foreach ($commands as $com) {
if ($com->isFile()) {
include_once($com->getRealPath());
}
}
}
}

Expand Down
32 changes: 25 additions & 7 deletions src/command/UpgradeProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

namespace PSFS\Command;

use PSFS\base\Router;
use PSFS\services\GeneratorService;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

Expand All @@ -14,21 +13,40 @@
$console
->register('psfs:update:project')
->setDescription(t('Actualización de configuraciones de proyectos en PSFS'))
->setCode(function (InputInterface $input, OutputInterface $output) {

$modules = Router::getInstance()->getDomains();
->setCode(function (InputInterface $input, OutputInterface $output) use ($console) {
// Clean up config files...
if(file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json')) {
rename(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json.bak');
}
if(file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json')) {
rename(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json.bak');
}
$modules = \PSFS\base\Router::getInstance()->getDomains();
$output->writeln("Hay un total de " . (count($modules) - 1) . " ha actualizar");
foreach ($modules as $module => $config) {
$clean_module = str_replace(['@', '\\', '/'], '', $module);
if ($clean_module !== 'ROOT') {
$output->write("\t- Actualizando módulo {$clean_module}");
GeneratorService::getInstance()->generateConfigurationTemplates($clean_module, $config['base']);
$configPath = $config['base'] . DIRECTORY_SEPARATOR . 'Config';
// Cleaning up config files and autoloader
if(file_exists($configPath . DIRECTORY_SEPARATOR . 'domains.json')) {
rename($configPath . DIRECTORY_SEPARATOR . 'config.php', $configPath . DIRECTORY_SEPARATOR . 'config.php.bak');
}
if(file_exists($configPath . DIRECTORY_SEPARATOR . 'propel.yml')) {
unlink($configPath . DIRECTORY_SEPARATOR . 'propel.yml');
}
\PSFS\services\GeneratorService::getInstance()->generateConfigurationTemplates($clean_module, $config['base']);
$output->writeln("\tDONE!");
}
}
$router = Router::getInstance();
$router = \PSFS\base\Router::getInstance();
$router->hydrateRouting();
$router->simpatize();
$output->writeln(t("Rutas del proyecto actualizadas con éxito"));
// Run the deployment command
$commandInput = new ArrayInput([
'command' => 'psfs:deploy:project',
]);
$console->run($commandInput, $output);
});

2 changes: 1 addition & 1 deletion src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function getallheaders(): array
/* @var $file SplFileInfo */
foreach ($finder as $file) {
$path = $file->getRealPath();
if (!in_array($path, $loaded_files)) {
if (!in_array($path, $loaded_files, true) && file_exists($path)) {
$loaded_files[] = $path;
require_once($path);
}
Expand Down
Loading