Example #1
0
 /**
  * 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;
 }
Example #2
0
 /**
  * Returns a unique identifier for the extension, such as: Vendor/Name
  *
  * @return string
  */
 public function getId()
 {
     return $this->innerExtension->getId();
 }