Просмотр файла app/Commands/AppPermission.php

Размер файла: 1.12Kb
  1. <?php
  2.  
  3. declare(strict_types=1);
  4.  
  5. namespace App\Commands;
  6.  
  7. use Phinx\Console\Command\AbstractCommand;
  8. use Symfony\Component\Console\Input\InputInterface;
  9. use Symfony\Component\Console\Output\OutputInterface;
  10. use Symfony\Component\Filesystem\Filesystem;
  11.  
  12. class AppPermission extends AbstractCommand
  13. {
  14. /**
  15. * {@inheritdoc}
  16. */
  17. protected function configure(): void
  18. {
  19. parent::configure();
  20.  
  21. $this->setName('app:permission')
  22. ->setDescription('Set file permissions');
  23. }
  24.  
  25. /**
  26. * Set permissions
  27. *
  28. * @param InputInterface $input
  29. * @param OutputInterface $output
  30. *
  31. * @return int
  32. */
  33. protected function execute(InputInterface $input, OutputInterface $output): int
  34. {
  35. $storage = glob(STORAGE . '/*', GLOB_ONLYDIR);
  36. $uploads = glob(UPLOADS . '/*', GLOB_ONLYDIR);
  37. $modules = [HOME . '/assets/modules'];
  38.  
  39. $dirs = array_merge($storage, $uploads, $modules);
  40.  
  41. $filesystem = new Filesystem();
  42. $filesystem->chmod($dirs, 0777);
  43.  
  44. $output->writeln('<info>Permissions set successfully.</info>');
  45.  
  46. return 0;
  47. }
  48. }