FOF30\Generator\Command\Init::getPath PHP Method

getPath() protected method

Ask the user the path for each of the files folders
protected getPath ( object $composer, string $key, string $default ) : string
$composer object The composer json object
$key string The key of the folder (backend)
$default string The default path to use
return string The user chosen path
    protected function getPath($composer, $key, $default)
    {
        $extra = $composer->extra ? $composer->extra->fof : false;
        $default_path = $extra && $extra->paths && $extra->paths->{$key} ? $extra->paths->{$key} : $default;
        // Keep asking while the path is not valid
        $path = false;
        $this->out("Location of " . $key . " files: [" . $default_path . "]");
        $path = $this->in();
        // Use the default path if needbe
        if (empty($path)) {
            $path = $default_path;
        }
        // Create the directory if necessary
        if (!is_dir($path)) {
            \JFolder::create(getcwd() . '/' . $path);
        }
        return $path;
    }