Get Console Dir

@return null|string
355608
public static function getConsoleDir()
    {
        $rootDir = sprintf('%s/../../../../../../../..', __DIR__);

        $paths = [
            'bin',
            'app',
        ];

        foreach ($paths as $path) {
            $fullPath = sprintf('%s/%s', $rootDir, $path);

            if (true === is_dir($fullPath) && true === file_exists(sprintf('%s/console', $fullPath))) {
                return $fullPath;
            }
        }

        return null;
    }
1177627
public function basePath()
    {
        if ($this->dirname && $this->basename) {
            return ($this->dirname .'/'. $this->basename);
        }

        return null;
    }
311112
private function getDirectory()
    {
        // Fallback to default directory if no storage path defined
        if (defined('CRAFT_STORAGE_PATH')) {
            $basePath = CRAFT_STORAGE_PATH;
        } else {
            $basePath = CRAFT_BASE_PATH . DIRECTORY_SEPARATOR . 'storage';
        }

        return $basePath . DIRECTORY_SEPARATOR . 'runtime' . DIRECTORY_SEPARATOR . 'htmlcache' . DIRECTORY_SEPARATOR;
    }
816865
public function getRootNamespace()
    {
        if (($psr4 = $this->get('autoload.psr-4')) === null) {
            return null;
        }

        foreach ($psr4 as $namespace => $namespacePaths) {
            foreach ((array)$namespacePaths as $namespacePath) {
                // The namespace path should be a subdirectory of the "src" directory
                if (mb_strpos(realpath($this->rootPath . '/' . $namespacePath), realpath($this->psr4RootPath)) === 0) {
                    return rtrim($namespace, '\\');
                }
            }
        }

        return null;
    }
1036796
protected function getConsole()
    {
        if (is_null($this->console)) {
            $console = new Console($this->app, $this->events, $this->app->version());
            $console->setName('Themosis Framework');

            return $this->console = $console->resolveCommands($this->commands);
        }

        return $this->console;
    }
116611
protected function getBaseDirectory()
    {
        if (! $this->fileSystem) {
            $this->fileSystem = $this->getServiceLocator()
                ->get(FileSystemService::SERVICE_ID)
                ->getDirectory($this->getFileSystemId());
        }

        return $this->fileSystem;
    }
238872
protected function getDataDirectoryPath() {
    $data_dir = $this->getEnvironment()->getDataDirectory();
    $config = $this->getConfiguration();
    return str_replace('{branch}', $config->getBranch(), $data_dir);
  }
328045
public function dir_readdir()
    {
        $object = current($this->_bucketList);
        if ($object !== false) {
            next($this->_bucketList);
        }

        return $object;
    }
965045
protected function getTraitDirectory()
    {
        if($config = $this->configFileMissing()) {
            return $this->error($config);
        }

        return 'app/' . rtrim($this->getConfigTraitDirectory(), '/\\') . '/';
    }
1361651
public static function getProjectRootDirectory(): string
    {
        if (null === self::$projectRootDirectory) {
            $reflection                 = new \ReflectionClass(ClassLoader::class);
            self::$projectRootDirectory = \dirname((string)$reflection->getFileName(), 3);
        }

        return self::$projectRootDirectory;
    }
1113342
public function getPublicDirectory()
    {
        if (isset($this->publicDirectory)) {
            return $this->publicDirectory;
        }
        
        $rootPkg = $this->composer->getPackage();
        
        if ($rootPkg) {
            $extra = $rootPkg->getExtra();
            
            if ($extra && ! empty($extra['public-dir'])) {
                return $this->publicDirectory = $extra['public-dir'];
            }
        }
        
        $common_public_dirs = [
            'public',
            'public_html',
            'htdocs',
            'httpdocs',
            'html',
            'web',
            'www',
        ];
        
        $public = null;
        
        foreach ($common_public_dirs as $dir) {
            if (file_exists($dir)) {
                $public = $dir;
                
                break;
            }
        }
        
        $publicDirQuestion = 'What is the public directory (web root) for this project?';
        
        if (! $public) {
            if ($this->io->isInteractive()) {
                return $this->publicDirectory = trim($this->ask($publicDirQuestion, $common_public_dirs[0]), '/');
            }
            
            return $this->publicDirectory = $common_public_dirs[0];
        }
        
        if ($this->io->isInteractive()) {
            return $this->publicDirectory = trim($this->ask($publicDirQuestion, $public), '/');
        }
        
        return $this->publicDirectory = $public;
    }
1309290
public function getDirectory() : ?string 
    {
        if ( ! $this->hasDirectory()) {
            $this->setDirectory($this->getDefaultDirectory());
        }
        return $this->directory;
    }
541726
public function get()
    {
        foreach ($this->_commands as $command) {
            $location = $this->_commandLocator->locate(basename($command));
            if ($location !== null) {
                return $location;
            }
        }

        return null;
    }
823495
protected function get_restore_content_dir() {
        $backupfile = null;
        $shortname = null;

        if (!empty($this->options['backupfile'])) {
            $backupfile = $this->options['backupfile'];
        } else if (!empty($this->options['templatecourse']) || is_numeric($this->options['templatecourse'])) {
            $shortname = $this->options['templatecourse'];
        }

        $errors = array();
        $dir = tool_uploadcourse_helper::get_restore_content_dir($backupfile, $shortname, $errors);
        if (!empty($errors)) {
            foreach ($errors as $key => $message) {
                $this->error($key, $message);
            }
            return false;
        } else if ($dir === false) {
            // We want to return null when nothing was wrong, but nothing was found.
            $dir = null;
        }

        if (empty($dir) && !empty($this->importoptions['restoredir'])) {
            $dir = $this->importoptions['restoredir'];
        }

        return $dir;
    }
322567
public function getPictureDir()
    {
        if (($sValue = $this->getViewConfigParam('picturedir')) === null) {
            $sValue = $this->getConfig()->getPictureUrl(null, $this->isAdmin());
            $this->setViewConfigParam('picturedir', $sValue);
        }

        return $sValue;
    }
1213025
protected function getRootDirectory()
    {
        if ($this->addon) {
            $directories = $this->addon->config('addon.directories');

            if (! $directories) {
                $directories = ['classes'];
            }

            return $this->addon->path($directories[0]);
        }
        else {
            return parent::getRootDirectory();
        }
    }
1333672
protected function findShell()
	{
		if (self::$shell)
		{
			return self::$shell;
		}

		$command = "/usr/bin/env %s -c 'echo Hello'";

		foreach (array('bash', 'zsh', 'ksh', 'csh') as $shell)
		{
			if (rtrim(shell_exec(sprintf($command, $shell))) === 'Hello')
			{
				self::$shell = $shell;

				return $shell;
			}
		}

		return null;
	}