/** * JBZoo CrossCMS * * This file is part of the JBZoo CCK package. * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * @package CrossCMS * @license MIT * @copyright Copyright (C) JBZoo.com, All rights reserved. * @link https://github.com/JBZoo/CrossCMS * @author Denis Smetannikov <*****@*****.**> */ ob_start(); if ($basepath = getenv('PATH_JOOMLA')) { $basepath = realpath($basepath); $_SERVER['DOCUMENT_ROOT'] = $basepath; $_SERVER['SCRIPT_FILENAME'] = $basepath . '/index.php'; require_once $basepath . '/index.php'; } elseif ($basepath = getenv('PATH_WORDPRESS')) { $basepath = realpath($basepath); $_SERVER['DOCUMENT_ROOT'] = $basepath; $_SERVER['SCRIPT_FILENAME'] = $basepath . '/index.php'; require_once $basepath . '/index.php'; } else { throw new \Exception('Undefined CMS Type!'); } $cmsResult = ob_get_contents(); ob_end_clean(); \JBZoo\PHPUnit\cliMessage($cmsResult); unset($cmsResult);
/** * Execute cli commands * * @param string $command * @param array $args * @param null $cwd * @param bool $verbose * @return string * @throws ProcessFailedException * @throws \Exception */ public static function exec($command, $args = array(), $cwd = null, $verbose = false) { if (!class_exists('\\Symfony\\Component\\Process\\Process')) { throw new \Exception("Symfony/Process package required for Cli::exec() method"); // @codeCoverageIgnore } $cmd = self::build($command, $args); $cwd = $cwd ? $cwd = realpath($cwd) : null; //@codeCoverageIgnoreStart if ($verbose) { // Only in testing mode if (function_exists('\\JBZoo\\PHPUnit\\cliMessage')) { \JBZoo\PHPUnit\cliMessage('Process: ' . $cmd); \JBZoo\PHPUnit\cliMessage('CWD: ' . $cwd); } else { Cli::out('Process: ' . $cmd); Cli::out('CWD: ' . $cwd); } } //@codeCoverageIgnoreEnd // execute command $process = new Process($cmd, $cwd); $process->run(); // executes after the command finishes if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } return $process->getOutput(); }
/** * @param string $message * @param bool $addEol */ public function out($message, $addEol = true) { if (function_exists('\\JBZoo\\PHPUnit\\cliMessage')) { \JBZoo\PHPUnit\cliMessage($message, $addEol); } else { Cli::out($message, $addEol); } }