Ejemplo n.º 1
0
Archivo: Plugin.php Proyecto: Jobu/core
 /**
  * Detect the contao installation root, version and configuration and set the TL_ROOT constant if not already exist.
  *
  * Existing values could originate from previous run or when run within contao.
  *
  * @param RootPackageInterface $package The package being processed.
  *
  * @return string|null
  *
  * @throws RuntimeException If the current working directory can not be determined.
  */
 public function getContaoRoot(RootPackageInterface $package)
 {
     if (!isset($this->contaoRoot)) {
         $roots = array_values(Environment::findContaoRoots($package));
         if (!isset($roots[0])) {
             return $this->contaoRoot = null;
         }
         $this->contaoRoot = $roots[0];
     }
     $systemDir = $this->contaoRoot . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR;
     $configDir = $systemDir . 'config' . DIRECTORY_SEPARATOR;
     $this->detectVersion($systemDir, $configDir, $this->contaoRoot);
     $this->loadConfig($configDir);
     return $this->contaoRoot;
 }
Ejemplo n.º 2
0
 /**
  * Ugly hack to check duplicate installation after plugin update.
  *
  * @param PackageInterface $package The package to check.
  *
  * @return void
  *
  * @throws DuplicateContaoException When the Contao core has been found.
  */
 private static function checkDuplicateInstallation(PackageInterface $package)
 {
     if ($package->getName() === 'contao/core' || in_array($package->getName(), Environment::$bundleNames)) {
         $roots = Environment::findContaoRoots();
         if (count($roots) > 1) {
             throw new DuplicateContaoException('Warning: Contao core was installed but has been found in project root, ' . 'to recover from this problem please restart the operation');
         }
     }
 }