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

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