CommandRendererBackground.php 889 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Shell;
  7. use Magento\Framework\OsInfo;
  8. class CommandRendererBackground extends CommandRenderer
  9. {
  10. /**
  11. * @var \Magento\Framework\OsInfo
  12. */
  13. protected $osInfo;
  14. /**
  15. * @param OsInfo $osInfo
  16. */
  17. public function __construct(OsInfo $osInfo)
  18. {
  19. $this->osInfo = $osInfo;
  20. }
  21. /**
  22. * Render command with arguments
  23. *
  24. * @param string $command
  25. * @param array $arguments
  26. * @return string
  27. */
  28. public function render($command, array $arguments = [])
  29. {
  30. $command = parent::render($command, $arguments);
  31. return $this->osInfo->isWindows() ?
  32. 'start /B "magento background task" ' . $command
  33. : str_replace('2>&1', '> /dev/null &', $command);
  34. }
  35. }