/** * Set application root absolute path * * @param string $appRoot * @throws Mage_Core_Exception */ public static function setRoot($appRoot = '') { if (self::$_appRoot) { return; } if ('' === $appRoot) { // automagically find application root by dirname of Mage.php $appRoot = dirname(__FILE__); } $appRoot = realpath($appRoot); if (is_dir($appRoot) and is_readable($appRoot)) { self::$_appRoot = $appRoot; } else { self::throwException($appRoot . ' is not a directory or not readable by this user'); } }
/** * Retrieve application root absolute path * * @return string * @throws Magento_Exception */ public static function getRoot() { if (!self::$_appRoot) { $appRootDir = __DIR__; if (!is_readable($appRootDir)) { throw new Magento_Exception("Application root directory '{$appRootDir}' is not readable."); } self::$_appRoot = $appRootDir; } return self::$_appRoot; }