/** * Remove a vendor-directory path. * @param string $path Path. */ public function removePath($path) { $path = Paths::convertRealPath($path); if (isset($this->paths[$path])) { unset($this->paths[$path]); } }
/** * Run build script. * @param string $root Package root. * @throws InstallException on failure. */ public function run($root) { $this->buildPath = $this->p('tmp/build/' . $this->name); if (!Utilities::dirExists($this->buildPath, true, true)) { throw new InstallException('Could not create build directory: ' . $this->buildPath); } $this->installPath = Paths::combinePaths($root, $this->name); if (!Utilities::dirExists($this->installPath, true, true)) { throw new InstallException('Could not create install directory: ' . $this->installPath); } if (isset($this->prepare)) { $this->info(tr('Preparing...')); call_user_func($this->prepare, $this); } $this->fetchSources(); if (isset($this->build)) { $this->info(tr('Building...')); call_user_func($this->build, $this); } if (isset($this->install)) { $this->info(tr('Installing...')); call_user_func($this->install, $this); } $this->manifest['name'] = $this->name; $this->manifest['version'] = $this->version; if (isset($this->manifestFile) and isset($this->manifest)) { $this->info(tr('Creating manifest...')); $manifestFile = $this->installPath . '/' . $this->manifestFile; file_put_contents($manifestFile, Json::prettyPrint($this->manifest)); } }
/** * Create application. * @param string $appPath Path to app-directory containing at least an * 'app.json' configuration file. * @param string $userPath Path to user-directory. * @param string $entryScript Name of entry script, e.g. 'index.php'. */ public function __construct($appPath, $userPath, $entryScript = 'index.php') { parent::__construct(); $this->logger = ErrorHandler::getInstance()->getLogger(); $appPath = Utilities::convertPath($appPath); $userPath = Utilities::convertPath($userPath); $manifestFile = $appPath . '/app.json'; if (file_exists($manifestFile)) { $manifest = Json::decodeFile($manifestFile); $manifest = array_merge($this->defaultManifest, $manifest); } else { $this->logger->error('Invalid application. "app.json" not found. Configuring default application.'); $this->noManifest = true; $manifest = $this->defaultManifest; } $this->manifest = $manifest; $this->m = new ModuleLoader(); $this->paths = new Paths(Paths::convertPath(getcwd()), $userPath); $this->paths->app = $appPath; $this->paths->user = $userPath; // $this->basePath = dirname($_SERVER['SCRIPT_NAME']); $this->entryScript = $entryScript; // Temporary work-around for weird SCRIPT_NAME. // When url contains a trailing dot such as // /app/index.php/admin./something // SCRIPT_NAME returns /app/index.php/admin./something instead of expected // /app/index.php $script = explode('/', $_SERVER['SCRIPT_NAME']); while (count($script) > 0) { if ($script[count($script) - 1] == $entryScript) { break; } array_pop($script); } $this->basePath = dirname(implode('/', $script)); // END work-around $this->name = $manifest['name']; $this->version = $manifest['version']; $this->namespace = $manifest['namespace']; Autoloader::getInstance()->addPath($this->namespace, $this->p('app')); $this->paths->Jivoo = \Jivoo\PATH; $this->paths->Core = \Jivoo\PATH . '/Core'; $file = new PhpStore($this->p('user/config.php')); $this->config = new Document(); $this->config['user'] = new Config($file); }