function FixtureManipulator::runComposerCommand

6 calls to FixtureManipulator::runComposerCommand()
FixtureManipulator::addConfig in core/modules/package_manager/tests/modules/fixture_manipulator/src/FixtureManipulator.php
Modifies the project root's composer.json properties.
FixtureManipulator::createPathRepo in core/modules/package_manager/tests/modules/fixture_manipulator/src/FixtureManipulator.php
Creates a path repo.
FixtureManipulator::modifyPackageConfig in core/modules/package_manager/tests/modules/fixture_manipulator/src/FixtureManipulator.php
Modifies a package's composer.json properties.
FixtureManipulator::removePackage in core/modules/package_manager/tests/modules/fixture_manipulator/src/FixtureManipulator.php
Removes a package.
FixtureManipulator::requirePackage in core/modules/package_manager/tests/modules/fixture_manipulator/src/FixtureManipulator.php
Requires a package.

... See full list

File

core/modules/package_manager/tests/modules/fixture_manipulator/src/FixtureManipulator.php, line 431

Class

FixtureManipulator
Manipulates a test fixture using Composer commands.

Namespace

Drupal\fixture_manipulator

Code

protected function runComposerCommand(array $command_options) : OutputCallbackInterface {
    $plain_output = new class  implements OutputCallbackInterface {
        // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable
        public string $stdout = '';
        // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable
        public string $stderr = '';
        
        /**
         * {@inheritdoc}
         */
        public function __invoke(OutputTypeEnum $type, string $buffer) : void {
            if ($type === OutputTypeEnum::OUT) {
                $this->stdout .= $buffer;
            }
            elseif ($type === OutputTypeEnum::ERR) {
                $this->stderr .= $buffer;
            }
        }
        
        /**
         * {@inheritdoc}
         */
        public function clearErrorOutput() : void {
            throw new \LogicException("Unexpected call to clearErrorOutput().");
        }
        
        /**
         * {@inheritdoc}
         */
        public function clearOutput() : void {
            throw new \LogicException("Unexpected call to clearOutput().");
        }
        
        /**
         * {@inheritdoc}
         */
        public function getErrorOutput() : array {
            throw new \LogicException("Unexpected call to getErrorOutput().");
        }
        
        /**
         * {@inheritdoc}
         */
        public function getOutput() : array {
            throw new \LogicException("Unexpected call to getOutput().");
        }

};
    
    /** @var \PhpTuf\ComposerStager\API\Process\Service\ComposerProcessRunnerInterface $runner */
    $runner = \Drupal::service(ComposerProcessRunnerInterface::class);
    $command_options[] = "--working-dir={$this->dir}";
    $runner->run($command_options, callback: $plain_output);
    return $plain_output;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.