/** * Add an extension to be registered. * * @param ExtensionInterface $extension * @param DirectoryInterface|null $baseDir * @param DirectoryInterface|null $webDir * @param string|null $composerName * * @throws \RuntimeException * * @return ResolvedExtension */ public function add(ExtensionInterface $extension, DirectoryInterface $baseDir = null, DirectoryInterface $webDir = null, $composerName = null) { if ($this->registered) { throw new \RuntimeException('Can not add extensions after they are registered.'); } // Set paths in the extension if ($baseDir !== null) { $extension->setBaseDirectory($baseDir); } if ($webDir !== null) { $extension->setWebDirectory($webDir); } // Determine if enabled $enabled = $this->config->get('extensions/' . $extension->getId(), true); if ($composerName !== null) { // Map composer name to ID $this->composerNames[$composerName] = $extension->getId(); // Check if enabled by composer name $enabled = $this->config->get("extensions/{$composerName}", $enabled); } // Instantiate resolved extension and mark enabled/disabled $resolved = (new ResolvedExtension($extension))->setEnabled($enabled); return $this->extensions[$extension->getId()] = $resolved; }
/** * Returns the root directory for the extension. * * @return \Bolt\Filesystem\Handler\DirectoryInterface */ public function getBaseDirectory() { return $this->innerExtension->getBaseDirectory(); }