vendor/contao/core-bundle/src/HttpKernel/Bundle/ContaoModuleBundle.php line 21

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of Contao.
  5. *
  6. * (c) Leo Feyer
  7. *
  8. * @license LGPL-3.0-or-later
  9. */
  10. namespace Contao\CoreBundle\HttpKernel\Bundle;
  11. use Symfony\Component\Filesystem\Path;
  12. use Symfony\Component\HttpKernel\Bundle\Bundle;
  13. /**
  14. * Allows registering legacy Contao modules as bundle.
  15. */
  16. final class ContaoModuleBundle extends Bundle
  17. {
  18. /**
  19. * Sets the module name and application root directory.
  20. */
  21. public function __construct(string $name, string $projectDir)
  22. {
  23. $this->name = $name;
  24. $this->path = Path::join($projectDir, 'system/modules', $this->name);
  25. if (is_dir($this->path)) {
  26. return;
  27. }
  28. // Backwards compatibility, $projectDir was previously set from kernel $rootDir
  29. $this->path = Path::join($projectDir, '../system/modules', $this->name);
  30. if (!is_dir($this->path)) {
  31. throw new \LogicException(sprintf('The module folder "system/modules/%s" does not exist.', $this->name));
  32. }
  33. }
  34. }