class LoggingCommitter

Same name in this branch
  1. 11.x core/modules/package_manager/tests/modules/package_manager_bypass/src/LoggingCommitter.php \Drupal\package_manager_bypass\LoggingCommitter

Logs Composer Stager's Committer process output to a file.

@internal This is an internal part of Package Manager and may be changed or removed at any time without warning. External code should not interact with this class.

Hierarchy

Expanded class hierarchy of LoggingCommitter

2 files declare their use of LoggingCommitter
LoggingCommitterTest.php in core/modules/package_manager/tests/src/Unit/LoggingCommitterTest.php
ServicesTest.php in core/modules/package_manager/tests/src/Kernel/ServicesTest.php

File

core/modules/package_manager/src/LoggingCommitter.php, line 24

Namespace

Drupal\package_manager
View source
class LoggingCommitter implements CommitterInterface {
    public function __construct(CommitterInterface $decorated, ConfigFactoryInterface $configFactory, TimeInterface $time) {
    }
    
    /**
     * {@inheritdoc}
     */
    public function commit(PathInterface $stagingDir, PathInterface $activeDir, ?PathListInterface $exclusions = NULL, ?OutputCallbackInterface $callback = NULL, int $timeout = ProcessInterface::DEFAULT_TIMEOUT) : void {
        $path = $this->configFactory
            ->get('package_manager.settings')
            ->get('log');
        if ($path) {
            $callback = new FileProcessOutputCallback($path, $callback);
            $callback(OutputTypeEnum::OUT, sprintf("### Committing changes from %s to %s\n", $stagingDir->absolute(), $activeDir->absolute()));
        }
        $start_time = $this->time
            ->getCurrentMicroTime();
        $this->decorated
            ->commit($stagingDir, $activeDir, $exclusions, $callback, $timeout);
        $end_time = $this->time
            ->getCurrentMicroTime();
        if ($callback) {
            $callback(OutputTypeEnum::OUT, sprintf("### Finished in %0.3f seconds\n", $end_time - $start_time));
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary
LoggingCommitter::commit public function
LoggingCommitter::__construct public function

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