Set application paths.

@since 1.0.1

@param string $baseDirectory → directory where class is instantiated
354036
private function setPaths($baseDirectory)
    {
        $this->setOption('ROOT', rtrim($baseDirectory, '/') . '/');
        $this->setOption('CORE', dirname(dirname(dirname(__DIR__))) . '/');
        $this->setOption('PUBLIC', self::ROOT() . 'public/');
        $this->setOption('TEMPLATES', self::ROOT() . 'templates/');
        $this->setOption('MODULES', self::ROOT() . 'modules/');
        $this->setOption('PLUGINS', self::ROOT() . 'plugins/');
        $this->setOption('COMPONENTS', self::ROOT() . 'components/');
    }
333982
public static function SetDirectory($dir) {
    if (!is_dir($dir)) {
      if (!@\mkdir($dir, 0700, TRUE)) {
        throw new \InvalidArgumentException("dir $dir does not exist and could not be created");
      }
    }

    self::$DIR = realpath($dir);
  }
2309
public function setRootDir($rootDir)
    {
        if (!is_dir($rootDir)) {
            throw new \InvalidArgumentException(
                sprintf('Invalid Application Configuration Directory: %s', $rootDir)
            );
        }

        $this->rootDir = $rootDir;
    }
543434
protected function applyOpenBaseDirSetting() {
		if($this->openBaseDirs) {
			$value = implode(PATH_SEPARATOR, $this->openBaseDirs);
			if(ini_get('open_basedir') != $value) {
				$this->forcePhpConsoleClassesAutoLoad();
				if(ini_set('open_basedir', $value) === false) {
					throw new \Exception('Unable to set "open_basedir" php.ini setting');
				}
			}
		}
	}
1113461
public function setPath(string $appRoot)
    {
        $this->path = new Path($appRoot, $this->coreRoot);

        $this->containerManager
            ->getContainer()
            ->instance(Path::class, $this->path);
    }
726695
public static function setPdfRendererPath($libraryBaseDir)
    {
        if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
            return false;
        }
        self::$pdfRendererPath = $libraryBaseDir;

        return true;
    }
347196
public static void setBaseDirectory(@NonNull File f){
        Preconditions.checkState(f.exists() && f.isDirectory(), "Specified base directory does not exist and/or is not a directory: %s", f.getAbsolutePath());
        baseDirectory = f;
    }
777648
protected function getDirectoryScanner(PhingFile $baseDir)
    {
        $this->fileset->setDir($baseDir);
        $this->fileset->setDefaultexcludes($this->useDefaultExcludes);

        return $this->fileset->getDirectoryScanner($this->project);
    }
1202991
public function setPath( $path )
	{
#		if( $path && !file_exists( $path ) )
#			throw new RuntimeException( 'Invalid path' );
		$path	= str_replace( DIRECTORY_SEPARATOR, "/", $path );
		$path	= preg_replace( "@(.+)/$@", "\\1", $path )."/";
		$this->path	= $path;
	}
560593
public function setPath($class, $path, $base = null)
    {
        $base = $base ? $base : $this->_base_path;
        $key  = $base ? $class.'-'.$base : $class;

        $this->__registry->set($key, $path);
    }
787695
public static function setChartRendererPath($libraryBaseDir)
    {
        if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
            return FALSE;
        }
        self::$_chartRendererPath = $libraryBaseDir;

        return TRUE;
    }
1199321
public function withBasePath($basePath)
    {
        if (!is_string($basePath)) {
            throw new InvalidArgumentException('Uri path must be a string');
        }
        if (!empty($basePath)) {
            $basePath = '/' . trim($basePath, '/'); // <-- Trim on both sides
        }
        $clone = clone $this;

        if ($basePath !== '/') {
            $clone->basePath = $this->filterPath($basePath);
        }

        return $clone;
    }
1240945
public final function addPrefix(
        string $prefix,
        $baseDirectory): LoaderInterface
    {
        $parsedPrefix = $this->parsePrefix($prefix);
        if (!array_key_exists($parsedPrefix, $this->prefix)) {
            if (is_array($baseDirectory)) {
                foreach ($baseDirectory as &$value) {
                    $value = $this->parseBaseDirectory((string) $value);
                }
                $this->prefix[$parsedPrefix] = $baseDirectory;
            } else if (is_string($baseDirectory)){
                $this->prefix[$parsedPrefix] = [
                    $this->parseBaseDirectory($baseDirectory)
                ];
            }
        }
        return $this;
    }
32586
public function setPath($path = null)
    {
        if (is_string($path)) {
            if ($path{0} !== '/') {
                $path = "/$path";
            }
        }
        else if (!is_null($path)) {
            throw new \InvalidArgumentException(
                "invalid value provided for 'path'; ".
                " expecting a string or null"
            );
        }
        $this->path = $path;
    }
1317097
protected function setPaths()
    {
        $pathPackage = realpath(__DIR__.'/../../../../');
        $pathBase = realpath(base_path());

        // Set CLI path.
        $this->pathCli = $pathBase.'/vendor/bin/'.$this::CLI_TOOL;
        if (!file_exists($this->pathCli)) {
            $this->pathCli = $pathPackage.'/vendor/bin/'.$this::CLI_TOOL;
        }

        // Set ruleset paths.
        $this->pathRulesetStock = $pathPackage.'/rulesets/'.$this::CLI_TOOL.'.xml';
        $this->pathRulesetLocal = $pathBase.'/'.$this::CLI_TOOL.'.xml';
        $this->pathRulesetLocalLegacy = $pathBase.'/app/'.$this::CLI_TOOL.'.xml';

        // Set active ruleset.
        $this->pathRuleset = $this->pathRulesetStock;
        if (is_readable($this->pathRulesetLocal)) {
            $this->pathRuleset = $this->pathRulesetLocal;
        } elseif (is_readable($this->pathRulesetLocalLegacy)) {
            $this->pathRuleset = $this->pathRulesetLocalLegacy;
        }
    }
819210
private function process($srcFiles, $basedir)
    {
        // Log
        $this->log("Processing files with base directory ($basedir) ", $this->loglevel);
        $targets = [];
        if ($this->targetFilePos !== null) {
            $addedFiles = [];
            foreach ($srcFiles as $count => $file) {
                if ($this->mapper !== null) {
                    $subTargets = $this->mapper->main($file);
                    if ($subTargets !== null) {
                        foreach ($subTargets as $subTarget) {
                            if ($this->relative) {
                                $name = $subTarget;
                            } else {
                                $name = (new PhingFile($this->destDir, $subTarget))->getAbsolutePath();
                            }
                            if ($this->forwardslash && PhingFile::$separator !== '/') {
                                $name = str_replace(PhingFile::$separator, '/', $name);
                            }
                            if (!isset($addedFiles[$name])) {
                                $targets[] = $name;
                                $addedFiles[] = $name;
                            }
                        }
                    }
                }
            }
        }
        $targetFiles = $targets;

        if (!$this->addsourcefile) {
            $srcFiles = [];
        }
        $orig = $this->commandline->getCommandline();
        $result = []; // range(0,count($orig) + count($srcFiles) + count($targetFiles));

        $srcIndex = count($orig);
        if ($this->srcFilePos !== null) {
            $srcIndex = $this->srcFilePos->getPosition();
        }
        if ($this->targetFilePos !== null) {
            $targetIndex = $this->targetFilePos->getPosition();

            if ($srcIndex < $targetIndex || ($srcIndex === $targetIndex && $this->srcIsFirst)) {
                // 0 --> srcIndex
                $result[] = $orig;

                // srcIndex --> targetIndex
                $result += array_slice($orig, $srcIndex + count($srcFiles), $targetIndex - $srcIndex, true);

                $result[] = $orig;
                $result[] = $targetFiles;
                $result = array_merge(... $result);

                // targetIndex --> end
                $result = array_merge(
                    array_slice(
                        $orig,
                        $targetIndex + count($srcFiles) + count($targetFiles),
                        count($orig) - $targetIndex,
                        true
                    ),
                    $result
                );
            } else {
                // 0 --> targetIndex
                $result[] = $orig;
                $result[] = $targetFiles;
                $result = array_merge(... $result);

                // targetIndex --> srcIndex
                $result = array_merge(
                    array_slice(
                        $orig,
                        $targetIndex + count($targetFiles),
                        $srcIndex - $targetIndex,
                        true
                    ),
                    $result
                );

                // srcIndex --> end
                $result = array_merge(
                    array_slice(
                        $orig,
                        $srcIndex + count($srcFiles) + count($targetFiles),
                        count($orig) - $srcIndex,
                        true
                    ),
                    $result
                );
                $srcIndex += count($targetFiles);
            }
        } else { // no targetFilePos

            // 0 --> srcIndex
            $result = array_merge(array_slice($orig, 0, $srcIndex, true), $result);
            // srcIndex --> end
            $result = array_merge(
                array_slice($orig, $srcIndex + count($srcFiles), count($orig) - $srcIndex, true),
                $result
            );
        }
        // fill in source file names
        foreach ($srcFiles as $i => $file) {
            if ($this->relative) {
                $src = $file;
            } else {
                $src = (new PhingFile($basedir, $file))->getAbsolutePath();
            }
            if ($this->forwardslash && PhingFile::$separator !== '/') {
                $src = str_replace(PhingFile::$separator, '/', $src);
            }
            if ($this->srcFilePos !== null && ($this->srcFilePos->getPrefix() !== ''
                    || $this->srcFilePos->getSuffix() !== '')
            ) {
                $src = $this->srcFilePos->getPrefix() . $src . $this->srcFilePos->getSuffix();
            }
            $result[$srcIndex + $i] = $src;
        }

        $this->commandline = new Commandline(implode(' ', $result));
        $this->commandline->setEscape($this->escape);
        $this->realCommand = (string) $this->commandline . $this->additionalCmds;

        [$returncode, $output] = $this->executeCommand();

        $this->maybeSetReturnPropertyValue($returncode);

        // Sets the output property
        if ($this->outputProperty) {
            $previousValue = $this->project->getProperty($this->outputProperty);
            if (!empty($previousValue)) {
                $previousValue .= "\n";
            }
            $this->project->setProperty($this->outputProperty, $previousValue . implode("\n", $output));
        }

        // Validating the 'return-code'
        if ($this->checkreturn && ($returncode !== 0)) {
            $this->throwBuildException("Task exited with code ($returncode)");
        }
    }
1197983
public static function run($baseDirectory, $type = 'app', $id = 'Default')
    {
        self::$id = $id;

        $that = self::getInstance();

        $that->setPaths($baseDirectory);
        $that->setUrls($baseDirectory, $type);
        $that->setIp();
        $that->runErrorHandler();
        $that->getSettings();
        $that->runHooks();
        $that->runComplements();
        $that->runRoutes();

        return true;
    }