2014-04-25 13:35:59 -04:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* cliMafe.php
|
|
|
|
|
*
|
|
|
|
|
* ProcessMaker Open Source Edition
|
|
|
|
|
* Copyright (C) 2011 Colosa Inc.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*
|
|
|
|
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
|
|
|
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
|
|
|
|
*
|
|
|
|
|
* @package workflow-engine-bin-tasks
|
|
|
|
|
*/
|
|
|
|
|
G::LoadSystem("g");
|
|
|
|
|
|
|
|
|
|
CLI::taskName('flush-cache');
|
|
|
|
|
CLI::taskDescription(<<<EOT
|
|
|
|
|
Flush cache of all workspaces of a given workspace
|
2015-07-20 12:02:33 -04:00
|
|
|
|
|
|
|
|
If no workspace is specified, then the cache will be flushed in all available workspaces.
|
2014-04-25 13:35:59 -04:00
|
|
|
EOT
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
CLI::taskArg('workspace', true, true);
|
|
|
|
|
CLI::taskRun('run_flush_cache');
|
|
|
|
|
|
|
|
|
|
function run_flush_cache($args, $opts)
|
2017-05-16 15:27:09 -04:00
|
|
|
{
|
|
|
|
|
if (count($args) === 1) {
|
|
|
|
|
flush_cache($args, $opts);
|
|
|
|
|
} else {
|
|
|
|
|
$workspaces = get_workspaces_from_args($args);
|
|
|
|
|
foreach ($workspaces as $workspace) {
|
|
|
|
|
passthru("./processmaker flush-cache " . $workspace->name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Flush the cache files for the specified workspace(s).
|
|
|
|
|
* If no workspace is specified, then the cache will be flushed in all available
|
|
|
|
|
* workspaces.
|
|
|
|
|
*
|
|
|
|
|
* @param type $args
|
|
|
|
|
* @param type $opts
|
|
|
|
|
*/
|
|
|
|
|
function flush_cache($args, $opts)
|
2014-04-25 13:35:59 -04:00
|
|
|
{
|
2017-05-15 14:49:15 -04:00
|
|
|
$rootDir = realpath(__DIR__ . "/../../../../");
|
2014-04-25 13:35:59 -04:00
|
|
|
$app = new Maveriks\WebApplication();
|
|
|
|
|
$app->setRootDir($rootDir);
|
|
|
|
|
$loadConstants = false;
|
|
|
|
|
$workspaces = get_workspaces_from_args($args);
|
|
|
|
|
|
2017-05-15 14:49:15 -04:00
|
|
|
if (!defined("PATH_C")) {
|
|
|
|
|
die("ERROR: seems processmaker is not properly installed (System constants are missing)." . PHP_EOL);
|
2014-04-25 13:35:59 -04:00
|
|
|
}
|
|
|
|
|
|
2017-05-15 14:49:15 -04:00
|
|
|
//Update singleton file by workspace
|
|
|
|
|
foreach ($workspaces as $workspace) {
|
2017-05-16 15:27:09 -04:00
|
|
|
eprint("Update singleton in workspace " . $workspace->name . " ... ");
|
2017-05-17 09:16:08 -04:00
|
|
|
Bootstrap::setConstantsRelatedWs($workspace->name);
|
2017-05-16 15:27:09 -04:00
|
|
|
$pathSingleton = PATH_DATA . "sites" . PATH_SEP . $workspace->name . PATH_SEP . "plugin.singleton";
|
|
|
|
|
$oPluginRegistry = PMPluginRegistry::loadSingleton($pathSingleton);
|
2017-05-19 16:20:44 -04:00
|
|
|
$items = \PMPlugin::getListAllPlugins($workspace->name);
|
2017-05-16 15:27:09 -04:00
|
|
|
foreach ($items as $item) {
|
2017-05-19 16:20:44 -04:00
|
|
|
if ($item->enabled === true) {
|
|
|
|
|
require_once($item->sFilename);
|
|
|
|
|
$details = $oPluginRegistry->getPluginDetails(basename($item->sFilename));
|
2017-05-16 15:27:09 -04:00
|
|
|
//Only if the API directory structure is defined
|
|
|
|
|
$pathApiDirectory = PATH_PLUGINS . $details->sPluginFolder . PATH_SEP . "src" . PATH_SEP . "Services" . PATH_SEP . "Api";
|
|
|
|
|
if (is_dir($pathApiDirectory)) {
|
2017-05-19 16:20:44 -04:00
|
|
|
$pluginSrcDir = PATH_PLUGINS . $details->sNamespace . PATH_SEP . 'src';
|
|
|
|
|
$loader = \Maveriks\Util\ClassLoader::getInstance();
|
|
|
|
|
$loader->add($pluginSrcDir);
|
|
|
|
|
$oPluginRegistry->registerRestService($details->sNamespace);
|
2017-05-17 09:38:48 -04:00
|
|
|
if (class_exists($details->sClassName)) {
|
|
|
|
|
$oPlugin = new $details->sClassName($details->sNamespace, $details->sFilename);
|
|
|
|
|
$oPlugin->setup();
|
2017-05-17 09:40:12 -04:00
|
|
|
file_put_contents($pathSingleton, $oPluginRegistry->serializeInstance());
|
2017-05-17 09:38:48 -04:00
|
|
|
}
|
2017-05-16 15:27:09 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
eprintln("DONE");
|
2017-05-15 14:49:15 -04:00
|
|
|
}
|
|
|
|
|
|
2017-05-16 15:27:09 -04:00
|
|
|
//flush the cache files
|
2017-05-15 14:49:15 -04:00
|
|
|
CLI::logging("Flush " . pakeColor::colorize("system", "INFO") . " cache ... ");
|
2014-04-25 13:35:59 -04:00
|
|
|
G::rm_dir(PATH_C);
|
|
|
|
|
G::mk_dir(PATH_C, 0777);
|
|
|
|
|
echo "DONE" . PHP_EOL;
|
|
|
|
|
|
|
|
|
|
foreach ($workspaces as $workspace) {
|
|
|
|
|
echo "Flush workspace " . pakeColor::colorize($workspace->name, "INFO") . " cache ... ";
|
|
|
|
|
|
|
|
|
|
G::rm_dir($workspace->path . "/cache");
|
|
|
|
|
G::mk_dir($workspace->path . "/cache", 0777);
|
|
|
|
|
G::rm_dir($workspace->path . "/cachefiles");
|
|
|
|
|
G::mk_dir($workspace->path . "/cachefiles", 0777);
|
2017-05-15 14:49:15 -04:00
|
|
|
if (file_exists($workspace->path . '/routes.php')) {
|
|
|
|
|
unlink($workspace->path . '/routes.php');
|
2016-06-24 09:50:31 -04:00
|
|
|
}
|
2014-04-25 13:35:59 -04:00
|
|
|
echo "DONE" . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|