Skip to content
Snippets Groups Projects
Commit bed6f440 authored by catch's avatar catch
Browse files

Issue #3479205 by alexpott, phenaproxima, catch: Wire Composer Stager into...

Issue #3479205 by alexpott, phenaproxima, catch: Wire Composer Stager into Package Manager's services.yml
parent 3bc3652d
No related branches found
No related tags found
16 merge requests!12227Issue #3181946 by jonmcl, mglaman,!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!5423Draft: Resolve #3329907 "Test2",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3478Issue #3337882: Deleted menus are not removed from content type config,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2062Issue #3246454: Add weekly granularity to views date sort,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #320691 passed with warnings
Pipeline: drupal

#320734

    Pipeline: drupal

    #320723

      Pipeline: drupal

      #320695

        ......@@ -20,8 +20,6 @@ services:
        Drupal\package_manager\TranslatableStringFactory:
        public: false
        decorates: 'PhpTuf\ComposerStager\API\Translation\Factory\TranslatableFactoryInterface'
        PhpTuf\ComposerStager\API\FileSyncer\Service\FileSyncerInterface:
        factory: ['@PhpTuf\ComposerStager\API\FileSyncer\Factory\FileSyncerFactoryInterface', 'create']
        Drupal\package_manager\LoggingBeginner:
        public: false
        decorates: 'PhpTuf\ComposerStager\API\Core\BeginnerInterface'
        ......@@ -105,3 +103,101 @@ services:
        $update_fetcher: '@update.fetcher'
        $key_value_factory: '@keyvalue'
        $key_value_expirable_factory: '@keyvalue.expirable'
        # Services from php-tuf/composer-stager package.
        PhpTuf\ComposerStager\API\Core\BeginnerInterface:
        class: PhpTuf\ComposerStager\Internal\Core\Beginner
        PhpTuf\ComposerStager\API\Core\CleanerInterface:
        class: PhpTuf\ComposerStager\Internal\Core\Cleaner
        PhpTuf\ComposerStager\API\Core\CommitterInterface:
        class: PhpTuf\ComposerStager\Internal\Core\Committer
        PhpTuf\ComposerStager\API\Core\StagerInterface:
        class: PhpTuf\ComposerStager\Internal\Core\Stager
        PhpTuf\ComposerStager\API\Environment\Service\EnvironmentInterface:
        class: PhpTuf\ComposerStager\Internal\Environment\Service\Environment
        PhpTuf\ComposerStager\API\FileSyncer\Service\FileSyncerInterface:
        class: PhpTuf\ComposerStager\Internal\FileSyncer\Service\FileSyncer
        PhpTuf\ComposerStager\API\Filesystem\Service\FilesystemInterface:
        class: PhpTuf\ComposerStager\Internal\Filesystem\Service\Filesystem
        PhpTuf\ComposerStager\API\Finder\Service\ExecutableFinderInterface:
        class: PhpTuf\ComposerStager\Internal\Finder\Service\ExecutableFinder
        PhpTuf\ComposerStager\API\Finder\Service\FileFinderInterface:
        class: PhpTuf\ComposerStager\Internal\Finder\Service\FileFinder
        PhpTuf\ComposerStager\API\Path\Factory\PathFactoryInterface:
        class: PhpTuf\ComposerStager\Internal\Path\Factory\PathFactory
        PhpTuf\ComposerStager\API\Path\Factory\PathListFactoryInterface:
        class: PhpTuf\ComposerStager\Internal\Path\Factory\PathListFactory
        PhpTuf\ComposerStager\API\Precondition\Service\ActiveAndStagingDirsAreDifferentInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\ActiveAndStagingDirsAreDifferent
        PhpTuf\ComposerStager\API\Precondition\Service\ActiveDirExistsInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\ActiveDirExists
        PhpTuf\ComposerStager\API\Precondition\Service\ActiveDirIsReadyInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\ActiveDirIsReady
        PhpTuf\ComposerStager\API\Precondition\Service\ActiveDirIsWritableInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\ActiveDirIsWritable
        PhpTuf\ComposerStager\API\Precondition\Service\BeginnerPreconditionsInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\BeginnerPreconditions
        PhpTuf\ComposerStager\API\Precondition\Service\CleanerPreconditionsInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\CleanerPreconditions
        PhpTuf\ComposerStager\API\Precondition\Service\CommitterPreconditionsInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\CommitterPreconditions
        PhpTuf\ComposerStager\API\Precondition\Service\CommonPreconditionsInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\CommonPreconditions
        PhpTuf\ComposerStager\API\Precondition\Service\ComposerIsAvailableInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\ComposerIsAvailable
        PhpTuf\ComposerStager\API\Precondition\Service\HostSupportsRunningProcessesInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\HostSupportsRunningProcesses
        PhpTuf\ComposerStager\API\Precondition\Service\NoAbsoluteSymlinksExistInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\NoAbsoluteSymlinksExist
        PhpTuf\ComposerStager\API\Precondition\Service\NoHardLinksExistInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\NoHardLinksExist
        PhpTuf\ComposerStager\API\Precondition\Service\NoLinksExistOnWindowsInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\NoLinksExistOnWindows
        PhpTuf\ComposerStager\API\Precondition\Service\NoNestingOnWindowsInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\NoNestingOnWindows
        PhpTuf\ComposerStager\API\Precondition\Service\NoSymlinksPointOutsideTheCodebaseInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\NoSymlinksPointOutsideTheCodebase
        PhpTuf\ComposerStager\API\Precondition\Service\NoUnsupportedLinksExistInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\NoUnsupportedLinksExist
        PhpTuf\ComposerStager\API\Precondition\Service\RsyncIsAvailableInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\RsyncIsAvailable
        PhpTuf\ComposerStager\API\Precondition\Service\StagerPreconditionsInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\StagerPreconditions
        PhpTuf\ComposerStager\API\Precondition\Service\StagingDirDoesNotExistInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\StagingDirDoesNotExist
        PhpTuf\ComposerStager\API\Precondition\Service\StagingDirExistsInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\StagingDirExists
        PhpTuf\ComposerStager\API\Precondition\Service\StagingDirIsReadyInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\StagingDirIsReady
        PhpTuf\ComposerStager\API\Precondition\Service\StagingDirIsWritableInterface:
        class: PhpTuf\ComposerStager\Internal\Precondition\Service\StagingDirIsWritable
        PhpTuf\ComposerStager\API\Process\Factory\ProcessFactoryInterface:
        class: PhpTuf\ComposerStager\Internal\Process\Factory\ProcessFactory
        PhpTuf\ComposerStager\API\Process\Service\ComposerProcessRunnerInterface:
        class: PhpTuf\ComposerStager\Internal\Process\Service\ComposerProcessRunner
        PhpTuf\ComposerStager\API\Process\Service\OutputCallbackInterface:
        class: PhpTuf\ComposerStager\Internal\Process\Service\OutputCallback
        PhpTuf\ComposerStager\API\Process\Service\ProcessInterface:
        class: PhpTuf\ComposerStager\Internal\Process\Service\Process
        PhpTuf\ComposerStager\API\Process\Service\RsyncProcessRunnerInterface:
        class: PhpTuf\ComposerStager\Internal\Process\Service\RsyncProcessRunner
        PhpTuf\ComposerStager\API\Translation\Factory\TranslatableFactoryInterface:
        class: PhpTuf\ComposerStager\Internal\Translation\Factory\TranslatableFactory
        PhpTuf\ComposerStager\API\Translation\Service\DomainOptionsInterface:
        class: PhpTuf\ComposerStager\Internal\Translation\Service\DomainOptions
        PhpTuf\ComposerStager\API\Translation\Service\LocaleOptionsInterface:
        class: PhpTuf\ComposerStager\Internal\Translation\Service\LocaleOptions
        PhpTuf\ComposerStager\API\Translation\Service\TranslatorInterface:
        class: PhpTuf\ComposerStager\Internal\Translation\Service\Translator
        PhpTuf\ComposerStager\Internal\Path\Service\PathHelperInterface:
        class: PhpTuf\ComposerStager\Internal\Path\Service\PathHelper
        public: false
        PhpTuf\ComposerStager\Internal\Process\Factory\SymfonyProcessFactoryInterface:
        class: PhpTuf\ComposerStager\Internal\Process\Factory\SymfonyProcessFactory
        public: false
        PhpTuf\ComposerStager\Internal\Process\Service\OutputCallbackAdapterInterface:
        class: PhpTuf\ComposerStager\Internal\Process\Service\OutputCallbackAdapter
        public: false
        PhpTuf\ComposerStager\Internal\Translation\Service\SymfonyTranslatorProxyInterface:
        class: PhpTuf\ComposerStager\Internal\Translation\Service\SymfonyTranslatorProxy
        public: false
        <?php
        declare(strict_types=1);
        namespace Drupal\package_manager;
        use Composer\InstalledVersions;
        use Drupal\Core\DependencyInjection\ContainerBuilder;
        use Drupal\Core\DependencyInjection\ServiceProviderInterface;
        /**
        * Defines dynamic container services for Package Manager.
        *
        * Scans the Composer Stager library and registers its classes in the Drupal
        * service container.
        *
        * @todo Refactor this if/when https://www.drupal.org/i/3111008 is fixed.
        *
        * @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.
        */
        final class PackageManagerServiceProvider implements ServiceProviderInterface {
        /**
        * {@inheritdoc}
        */
        public function register(ContainerBuilder $container): void {
        $path = InstalledVersions::getInstallPath('php-tuf/composer-stager') . '/src';
        // Certain subdirectories of Composer Stager shouldn't be scanned for
        // services.
        $ignore_directories = [
        $path . '/API/Exception',
        $path . '/Internal/Helper',
        $path . '/Internal/Path/Value',
        $path . '/Internal/Translation/Value',
        ];
        // As we scan for services, compile a list of which classes implement which
        // interfaces so that we can set up aliases for interfaces that are only
        // implemented by one class (to facilitate autowiring).
        $interfaces = [];
        // Find all `.php` files in Composer Stager which aren't in the ignored
        // directories.
        $iterator = new \RecursiveDirectoryIterator($path, \FilesystemIterator::CURRENT_AS_SELF | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS);
        $iterator = new \RecursiveCallbackFilterIterator($iterator, static function (\SplFileInfo $current) use ($ignore_directories): bool {
        if ($current->isDir()) {
        return !in_array($current->getPathname(), $ignore_directories, TRUE);
        }
        return $current->getExtension() === 'php';
        });
        $iterator = new \RecursiveIteratorIterator($iterator);
        /** @var \SplFileInfo $file */
        foreach ($iterator as $file) {
        // Convert the file name to a class name.
        $class_name = substr($file->getPathname(), strlen($path) + 1, -4);
        $class_name = 'PhpTuf\\ComposerStager\\' . str_replace(DIRECTORY_SEPARATOR, '\\', $class_name);
        // Don't register interfaces and abstract classes as services.
        $reflector = new \ReflectionClass($class_name);
        if ($reflector->isInterface() || $reflector->isAbstract()) {
        continue;
        }
        foreach ($reflector->getInterfaceNames() as $interface) {
        $interfaces[$interface][] = $class_name;
        }
        // Register the class as an autowired, private service.
        $container->register($class_name)
        ->setClass($class_name)
        ->setAutowired(TRUE)
        ->setPublic(FALSE);
        }
        // Create aliases for interfaces that are only implemented by one class.
        // Ignore interfaces that already have a service alias.
        foreach ($interfaces as $interface_name => $implementations) {
        if (count($implementations) === 1 && !$container->hasAlias($interface_name)) {
        $container->setAlias($interface_name, $implementations[0]);
        }
        }
        }
        }
        ......@@ -104,6 +104,11 @@ public function testCoreServiceAliases(): void {
        continue;
        }
        // Skip IDs that are interfaces already.
        if (interface_exists($id)) {
        continue;
        }
        // Expect standalone classes to be aliased.
        $implements = class_implements($class);
        if (!$implements) {
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment