setRootDir
Sets the application root directory
(This is typically unneeded except for tests)

@param string $rootDir
@return self $this
2309
public function setRootDir($rootDir)
    {
        if (!is_dir($rootDir)) {
            throw new \InvalidArgumentException(
                sprintf('Invalid Application Configuration Directory: %s', $rootDir)
            );
        }

        $this->rootDir = $rootDir;
    }
1298919
public function setCoreContextTreeSortdir($value)
    {
        $this->setFieldName('context_tree_sortdir');
        $this->loadObject(true);
        $this->setFieldValue($value);

        return $this;
    }
1069018
private static function _setupRoot()
	{
		if ( !empty(self::$root) ) {
			// avoid duplicating efforts... only set root if it's not already set 
			return;
		}
		
		if ( defined('ROOT') ) {
			self::$root = rtrim(ROOT, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
		}
		else if ( !empty($GLOBALS['baseDir']) ) {
			self::$root = rtrim($GLOBALS['baseDir'], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
		}
		else if ( strpos(__FILE__, DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR) !== false ) {
			// fall back to guessing the project root from the path...
			// we're in /vendor/datto/core-enumerator/src/Core

			$path = __FILE__;
			// up 5 levels
			while (!file_exists("$path/autoload.php")) {
				$path = dirname($path);
			}
			
			$path = dirname($path);

			self::$root = $path . DIRECTORY_SEPARATOR;
		}
		else if ( class_exists("Composer\\Autoload\\ClassLoader") ) {
			// go up until we find vendor/autoload.php - last resort
			$path = dirname(__FILE__);
			while ( $path && !file_exists($path . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php') ) {
				$path = dirname($path);
			}

			if ( !empty($path) ) {
				var_dump($path);
				self::$root = $path . DIRECTORY_SEPARATOR;
			}
		}

		if ( empty(self::$root) ) {
			throw new \Exception("Unable to determine project base directory");
		}
	}
410255
public function setOutdir($dir)
    {
        parent::setOutdir($dir);
        $this->storage->setOutdir($dir);

        return $this;
    }
534028
public function leaveLegacyRootDir()
    {
        $previousDir = $this->previousRunningDir;
        if (!$previousDir) {
            if ($this->logger) {
                $this->logger->warning(
                    "Trying to leave legacy root dir without a previously executing dir. Falling back to '$this->webRootDir'"
                );
            }
            $previousDir = $this->webRootDir;
        }

        $this->previousRunningDir = null;
        if ($this->logger) {
            $this->logger->debug("Legacy kernel: Leaving '$this->legacyRootDir' for '$previousDir'");
        }
        chdir($previousDir);
    }
121685
public function getRootDir()
    {
        static $dir;
        if (empty($dir)) {
            $rc = new \ReflectionClass(get_class($this));
            $dir = dirname(dirname($rc->getFileName()));
        }
        return $dir;
    }
636234
public function setOutputRootFolder(string $outputRootFolder): self
    {
        assert(empty($outputRootFolder) === false);

        $this->outputRootFolder = $outputRootFolder;

        $this->reset();

        return $this;
    }
382247
public function setProjectDirectory(string $dir): Application
    {
        if (is_dir($dir)) {
            $this->projectDir = $dir;
        }

        return $this;
    }
1233777
public function setRoot($root)
    {
        // do nothing if root isn't a valid prefix
        if (empty($root)) {
            return null;
        }

        // Kill slash padding and add a trailing slash afterwards
        $root = trim($root, '/');
        $root .= '/';
        $this->root = $root;
    }
863775
protected function createRootFolder()
    {
        $this->rootFolder = $this->createFolder($this->baseFolderRealPath, uniqid('xlsx', true));
        return $this;
    }
1360460
public function setSortDir($dir)
    {
        if (in_array($dir, [ self::DIR_ASC, self::DIR_DESC ]))
            $this->sortDir = $dir;
        else
            $this->sortDir = self::DIR_ASC;

        return $this;
    }
499063
protected function buildDirectory(DirectoryPath $root, SplFileInfo $splDirectory = null)
    {
        $relativeDirectoryPath = '';
        if (null !== $splDirectory) {
            $relativeDirectoryPath = $splDirectory->getRelativePathName();
        }

        $directory = new Directory(
            $this->getBasePath()->toAbsoluteFileSystemString(),
            $root->toRelativeFileSystemString(),
            $relativeDirectoryPath . DIRECTORY_SEPARATOR
        );

        return $directory;
    }
1318872
public function setRootDirectory($path)
    {
        if (@file_exists($path) && is_dir($path)) {
            $this->_root_dir = $path;
        } else {
            throw new InvalidArgumentException(
                sprintf('Root package directory "%s" not found !', $path)
            );
        }
        return $this;
    }
798987
public function configureIniStore( $configDir=null)
    {
        $this->configDir = $configDir                                           // case 1)
            ? $configDir
            : ( isset($_ENV['BOTK_CONFIGDIR'])                                    // case 2
                ? $_ENV['BOTK_CONFIGDIR'] 
                : (dirname(dirname($_SERVER['SCRIPT_FILENAME'])) . '/configs')
               ); // case 3
                
        return $this;
    }
398619
public function setRoot(string $root = "F") : CNabuDataObject
    {
        if ($root === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$root")
            );
        }
        $this->setValue('nb_role_root', $root);
        
        return $this;
    }
777554
public function getRoot(): self
    {
        return new self($this->uri->withPath('/'), $this->apiClient, $this->validator);
    }
73312
protected function expandAppDirs(ConfigInterface $config, $rootDir) {
        if (!is_string($rootDir))                          throw new IllegalTypeException('Illegal type of config option "app.dir.root": '.gettype($rootDir));
        if (!strlen($rootDir) || isRelativePath($rootDir)) throw new InvalidArgumentException('Invalid config option "app.dir.root": "'.$rootDir.'" (not an absolute path)');

        $rootDir = rtrim(str_replace('\\', '/', $rootDir), '/');
        $dirs = $config->get('app.dir', []);
        $this->expandDirsRecursive($dirs, $rootDir);

        $config->set('app.dir', $dirs);                     // store everything back
    }