Performs full system installation
@param array $data
@param array $cli_route
@return array
542754
public function process(array $data, array $cli_route = array())
    {
        $result = null;
        $this->hook->attach('install.before', $data, $result, $cli_route, $this);

        $default_result = array(
            'message' => '',
            'severity' => '',
            'redirect' => null
        );

        if (isset($result)) {
            return array_merge($default_result, (array) $result);
        }

        $result = $this->callHandler($data['installer'], $data);
        $this->hook->attach('install.after', $data, $result, $cli_route, $this);
        return array_merge($default_result, (array) $result);
    }
398654
public function install(array $data, $db)
    {
        $this->db = $db;
        $this->data = $data;

        try {
            $this->start();
            $this->process();
            return $this->finish();
        } catch (Exception $ex) {
            return array(
                'redirect' => '',
                'severity' => 'warning',
                'message' => $ex->getMessage()
            );
        }
    }
1305501
public function need($path, array $data = [])
    {
        $this->needData = [
            'path' => Container::get('config')->get('app_full_path') . '/views/' . $path . '.html',
            'data' => $data,
        ];
        unset($path, $data);
        extract($this->needData['data']);
        include $this->needData['path'];
    }
330609
public static function getRouterParametersFromData(array $data): array
    {
        assert(array_key_exists(self::KEY_ROUTER_PARAMS, $data));
        $result = $data[self::KEY_ROUTER_PARAMS];
        assert(empty($result) === false);

        return $result;
    }
915479
private function process($command, array $data = [])
    {
        return $this->parse(
            $this->cURL(
                $this->queryString(
                    array_merge([
                        'command' => $command
                    ], $data)
                )
            )
        );
    }
248682
private function bootForJob()
    {
        if (!isCLI()) {
            abort(500, "Somehow, you are not running this from a command line interface.");
        }

        $this->setErrorConfigurations();

        //Match routes
        $args = Args::parse();
        $target = CLIRouter::getInstance()->matchCommand($args);

        return [$args, $target];
    }
1312504
static public function view($route, $view = null, array $data = [])
    {
        self::$instance->register('GET', $route, null, $view, $data);
    }
785749
static function init() {

		switch( PHP_SAPI ) {
		// Ideally we want to be runnning as CLI
		case 'cli':
			break;
		// Special conditions to ensure CGI runs as CLI
		case 'cgi':
			// Ensure resource constants are defined
			if( ! defined('STDERR') ){
				define( 'STDERR', fopen('php://stderr', 'w') );
			}
			if( ! defined('STDOUT') ){
				define( 'STDOUT', fopen('php://stdout', 'w') );
			}
			break;
		default:
			echo "Command line only\n";
			exit(1);
		}
		
		// Default error logger function
		PLUG::set_error_logger( array(__CLASS__,'format_logline') );
		
		// parse command line arguments from argv global
		global $argv, $argc;
		// first cli arg is always current script. second arg will be script arg passed to shell wrapper
		for( $i = 1; $i < $argc; $i++ ){
			$arg = $argv[ $i ];
			
			// Each command line argument may take following forms:
			//  1. "Any single argument", no point parsing this unless it follows #2 below
			//  2. "-aBCD", one or more switches, parse into 'a'=>true, 'B'=>true, and so on
			//  3. "-a value", flag used with following value, parsed to 'a'=>'value'
			//  4. "--longoption", GNU style long option, parse into 'longoption'=>true
			//  5. "--longoption=value", as above, but parse into 'longoption'=>'value'
			//  6."any variable name = any value" 
			
			$pair = explode( '=', $arg, 2 );
			if( isset($pair[1]) ){
				$name = trim( $pair[0] );
				if( strpos($name,'--') === 0 ){
					// #5. trimming "--" from option, tough luck if you only used one "-"
					$name = trim( $name, '-' );
				}
				// else is #6, any pair
				$name and self::$args[$name] = trim( $pair[1] );
			}
			
			else if( strpos($arg,'--') === 0 ){
				// #4. long option, no value
				$name = trim( $arg, "-\n\r\t " );
				$name and self::$args[ $name ] = true;
			}
			
			else if( $arg && $arg{0} === '-' ){
				$flags = preg_split('//', trim($arg,"-\n\r\t "), -1, PREG_SPLIT_NO_EMPTY );
				foreach( $flags as $flag ){
					self::$args[ $flag ] = true;
				}
				// leave $flag set incase a value follows.
				continue;
			}

			// else is a standard argument. use as value only if it follows a flag, e.g "-a apple"
			else if( isset($flag) ){
				self::$args[ $flag ] = trim( $arg );
			}

			// dispose of last flag
			unset( $flag );
			// next arg 
		}
	}
296062
public static function getArgv(): array
    {
        if (PHP_SAPI != 'cli') {
            throw new CliException('Can not get $argv because script is not called from CLI');
        }

        if (static::$argv !== null) {
            return static::$argv;
        }

        global $argv;

        if (!isset($argv) || !is_array($argv)) {
            throw new CliException('Can not access the $argv variable. You\'re probably not in the CLI env.');
        }

        static::$argv = $argv;
        return static::$argv;
    }
1150362
public function route($data)
    {
        if (is_array($data)) {
            $path = $data[0];
            $pkg = $data[1];
        } else {
            $path = $data;
        }

        $path = trim($path, '/');
        $pkgHandle = null;
        if ($pkg) {
            if (is_object($pkg)) {
                $pkgHandle = $pkg->getPackageHandle();
            } else {
                $pkgHandle = $pkg;
            }
        }

        $route = '/ccm';
        if ($pkgHandle) {
            $route .= "/{$pkgHandle}";
        } else {
            $route .= '/system';
        }

        $route .= "/{$path}";

        return $route;
    }
164200
private function setupRoutables()
    {
        $app = $this;
        // For now, need to rely on a catch-all...
        $this->get(
            '{catchall:.*}',
            function (
                RequestInterface $request,
                ResponseInterface $response,
                array $args
            ) use ($app) {
                $config = $app->config();
                $routables = $config['routables'];
                if ($routables === null || count($routables) === 0) {
                    return $this['notFoundHandler']($request, $response);
                }
                $routeFactory = $this['route/factory'];
                foreach ($routables as $routableType => $routableOptions) {
                    $route = $routeFactory->create($routableType, [
                        'path' => $args['catchall'],
                        'config' => $routableOptions
                    ]);
                    if ($route->pathResolvable($this)) {
                        $this['logger']->debug(
                            sprintf('Loaded routable "%s" for path %s', $routableType, $args['catchall'])
                        );
                        return $route($this, $request, $response);
                    }
                }

                // If this point is reached, no routable has provided a callback. 404.
                return $this['notFoundHandler']($request, $response);
            }
        );
    }
121172
private function resolveSchemasFromRoutes(array $data, $basePath)
    {
        $schemas = [];
        $type    = SystemAbstract::TYPE_ROUTES;

        if (isset($data[$type]) && is_array($data[$type])) {
            foreach ($data[$type] as $name => $row) {
                // resolve includes
                $row = IncludeDirective::resolve($row, $basePath, $type);

                if (isset($row['methods']) && is_array($row['methods'])) {
                    foreach ($row['methods'] as $method => $config) {
                        // parameters
                        if (isset($config['parameters']) && !$this->isName($config['parameters'])) {
                            $schema = $this->resolveSchema($config['parameters'], $basePath);
                            $name   = NameGenerator::getSchemaNameFromSource($config['parameters']);

                            $schemas[$name] = $schema;
                        }

                        // request
                        if (isset($config['request']) && !$this->isName($config['request'])) {
                            $schema = $this->resolveSchema($config['request'], $basePath);
                            $name   = NameGenerator::getSchemaNameFromSource($config['request']);

                            $schemas[$name] = $schema;
                        }

                        // responses
                        if (isset($config['response']) && !$this->isName($config['response'])) {
                            $schema = $this->resolveSchema($config['response'], $basePath);
                            $name   = NameGenerator::getSchemaNameFromSource($config['response']);

                            $schemas[$name] = $schema;
                        } elseif (isset($config['responses']) && is_array($config['responses'])) {
                            foreach ($config['responses'] as $code => $response) {
                                if (!$this->isName($response)) {
                                    $schema = $this->resolveSchema($response, $basePath);
                                    $name   = NameGenerator::getSchemaNameFromSource($response);

                                    $schemas[$name] = $schema;
                                }
                            }
                        }
                    }
                }
            }
        }

        return $schemas;
    }
757486
public function add($path, $data=[], $internal = false)
  {
    if ( substr($path, 0, 2) === './' ){
      $path = $this->say_dir().substr($path, 1);
    }
    if ( $route = $this->mvc->get_route($path, $internal ? 'private' : 'public') ){
      $o = new controller($this->mvc, $route, $data);
      $o->process();
      return $o;
    }
    return false;
  }
1310708
private function resolveActionsFromRoutes(array $data, $basePath)
    {
        $actions = [];
        $type    = SystemAbstract::TYPE_ROUTES;

        if (isset($data[$type]) && is_array($data[$type])) {
            foreach ($data[$type] as $name => $row) {
                // resolve includes
                $row = IncludeDirective::resolve($row, $basePath, $type);

                if (isset($row['methods']) && is_array($row['methods'])) {
                    foreach ($row['methods'] as $method => $config) {
                        // action
                        if (isset($config['action']) && !$this->isName($config['action'])) {
                            $name = NameGenerator::getActionNameFromSource($config['action']);

                            $actions[$name] = [
                                'class' => $config['action']
                            ];
                        }
                    }
                }
            }
        }

        return $actions;
    }
907684
protected function generateRoutingData(): array
	{
		$parsedRoutes = [];
		$parser = new FR\RouteParser\Std();
		$dispatcherDataGenerator = new FR\DataGenerator\GroupCountBased();
		foreach ($this->routes as $routeName => $route)
		{
			$parsedRoute = $parser->parse($route->getPath());
			foreach ($route->getAllowedMethods() ?? ['*'] as $httpMethod)
			{
				foreach ($parsedRoute as $segments)
				{
					$dispatcherDataGenerator->addRoute($httpMethod, $segments, $routeName);
				}
			}
			$parsedRoutes[$routeName] = $parsedRoute;
		}
		return [$dispatcherDataGenerator->getData(), $parsedRoutes];
	}
1031254
public function setupRoutes()
    {
        $routes = $this->config();

        if (PHP_SAPI == 'cli') {
            $scripts = ( isset($routes['scripts']) ? $routes['scripts'] : [] );
            foreach ($scripts as $scriptIdent => $scriptConfig) {
                $this->setupScript($scriptIdent, $scriptConfig);
            }
        } else {
            $templates = ( isset($routes['templates']) ? $routes['templates'] : [] );
            foreach ($templates as $routeIdent => $templateConfig) {
                $this->setupTemplate($routeIdent, $templateConfig);
            }

            $actions = ( isset($routes['actions']) ? $routes['actions'] : [] );
            foreach ($actions as $actionIdent => $actionConfig) {
                $this->setupAction($actionIdent, $actionConfig);
            }
        }
    }
1024532
private function setupData($input, $output)
    {
        $command = $this->getApplication()->find('networking:initcms:data-setup');
        $arguments = [
            'command' => 'networking:initcms:data-setup',
            '--drop' => true,
            '--use-acl' => $input->getOption('use-acl'),
        ];

        $input = new ArrayInput($arguments);

        return $command->run($input, $output);
    }