vendor/contao/manager-bundle/src/EventListener/InstallCommandListener.php line 35

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\ManagerBundle\EventListener;
  11. use Contao\CoreBundle\Command\InstallCommand;
  12. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  13. use Symfony\Component\Filesystem\Filesystem;
  14. use Symfony\Component\Filesystem\Path;
  15. /**
  16. * @internal
  17. */
  18. class InstallCommandListener
  19. {
  20. private string $projectDir;
  21. public function __construct(string $projectDir)
  22. {
  23. $this->projectDir = $projectDir;
  24. }
  25. /**
  26. * Adds the initialize.php file.
  27. */
  28. public function __invoke(ConsoleTerminateEvent $event): void
  29. {
  30. if (!$event->getCommand() instanceof InstallCommand) {
  31. return;
  32. }
  33. (new Filesystem())
  34. ->copy(
  35. __DIR__.'/../Resources/skeleton/system/initialize.php',
  36. Path::join($this->projectDir, 'system/initialize.php'),
  37. true
  38. )
  39. ;
  40. }
  41. }