/** * Creates the context. * * @param string|null $homeDir The path to the home directory * or `null` if none exists. * @param Config $config The configuration. * @param ConfigFile $configFile The configuration file or * `null` if none exists. * @param EventDispatcherInterface $dispatcher The event dispatcher. */ public function __construct($homeDir, Config $config, ConfigFile $configFile = null, EventDispatcherInterface $dispatcher = null) { Assert::nullOrDirectory($homeDir, 'The home directory %s is not a directory.'); $this->homeDir = $homeDir ? Path::canonicalize($homeDir) : null; $this->config = $config; $this->dispatcher = $dispatcher ?: new EventDispatcher(); $this->configFile = $configFile; }
/** * Sets the root directory of the managed Puli project. * * @param string|null $rootDir The root directory of the managed Puli * project or `null` to start Puli outside of a * specific project. */ public function setRootDirectory($rootDir) { if ($this->started) { throw new LogicException('Puli is already started'); } Assert::nullOrDirectory($rootDir); $this->rootDir = $rootDir ? Path::canonicalize($rootDir) : null; }