9 use Composer\Console\Application;
    12 use Symfony\Component\Console\Command\Command;
    13 use Symfony\Component\Console\Input\ArrayInput;
    14 use Symfony\Component\Console\Input\InputInterface;
    15 use Symfony\Component\Console\Input\InputOption;
    16 use Symfony\Component\Console\Output\OutputInterface;
    33     private $sampleDataDependency;
    39     private $arrayInputFactory;
    44     private $applicationFactory;
    55         \Symfony\Component\Console\Input\ArrayInputFactory $arrayInputFactory,
    56         \Composer\Console\ApplicationFactory $applicationFactory
    59         $this->sampleDataDependency = $sampleDataDependency;
    60         $this->arrayInputFactory = $arrayInputFactory;
    61         $this->applicationFactory = $applicationFactory;
    62         parent::__construct();
    70         $this->setName(
'sampledata:deploy')
    71             ->setDescription(
'Deploy sample data modules for composer-based Magento installations');
    73             self::OPTION_NO_UPDATE,
    75             InputOption::VALUE_NONE,
    76             'Update composer.json without executing composer update'    84     protected function execute(InputInterface $input, OutputInterface 
$output)
    86         $rootJson = json_decode($this->filesystem->getDirectoryRead(
DirectoryList::ROOT)->readFile(
"composer.json"));
    87         if (!isset($rootJson->version)) {
    89             $output->writeln(
'<info>' . 
'Git installations must deploy sample data from GitHub; see https://devdocs.magento.com/guides/v2.3/install-gde/install/sample-data-after-clone.html for more information.' . 
'</info>');
    92         $this->updateMemoryLimit();
    93         $this->createAuthFile();
    94         $sampleDataPackages = $this->sampleDataDependency->getSampleDataPackages();
    95         if (!empty($sampleDataPackages)) {
    97             $commonArgs = [
'--working-dir' => 
$baseDir, 
'--no-progress' => 1];
    98             if ($input->getOption(self::OPTION_NO_UPDATE)) {
    99                 $commonArgs[
'--no-update'] = 1;
   103                 $packages[] = 
"$name:$version";
   105             $commonArgs = array_merge([
'packages' => $packages], $commonArgs);
   106             $arguments = array_merge([
'command' => 
'require'], $commonArgs);
   115                     '<info>' . 
'There is an error during sample data deployment. Composer file will be reverted.'   121             $output->writeln(
'<info>' . 
'There is no sample data for current set of modules.' . 
'</info>');
   133     private function createAuthFile()
   140             } 
catch (\Exception $e) {
   141                 $message = 
'Error in writing Auth file '   143                     . 
'. Please check permissions for writing.';
   152     private function updateMemoryLimit()
   156             $memoryLimit = trim(
ini_get(
'memory_limit'));
   157             if ($memoryLimit != -1 && $this->getMemoryInBytes($memoryLimit) < 756 * 1024 * 1024) {
   158                 @
ini_set(
'memory_limit', 
'756M');
   167     private function getMemoryInBytes(
$value)
   169         $unit = strtolower(substr(
$value, -1, 1));
   173                 $value *= 1024 * 1024 * 1024;
 
ini_set($varName, $newValue)
 
__construct(\Magento\Framework\Filesystem $filesystem, \Magento\SampleData\Model\Dependency $sampleDataDependency, \Symfony\Component\Console\Input\ArrayInputFactory $arrayInputFactory, \Composer\Console\ApplicationFactory $applicationFactory)
 
if(!isset($_GET['name'])) $name