Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295724

Support resource key in services.yml

$
0
0

Problem/Motivation

Symfony allows you to specify a resource key in your services.yml file. This allows you to search a location and create services automatically.

In Symfony it often looks like

# config/services.yaml
services:
    # default configuration for services in *this* file
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
        public: false       # Allows optimizing the container by removing unused services; this also means
                            # fetching services directly from the container via $container->get() won't work.
                            # The best practice is to be explicit about your dependencies anyway.

    # makes classes in src/ available to be used as services
    # this creates a service per class whose id is the fully-qualified class name
    App\:
        resource: '../src/*'
        exclude: '../src/{Entity,Migrations,Tests,Kernel.php}'

    # ...

Whilst resource: './src/*' would create way to many services if you organise your project so that all services are in src/services then this could be useful especially when combined with and #3021803: Enable autowiring the container and #3021898: Support _defaults key in service.yml files.

Proposed resolution

Implement this by copying code from YamlFileLoader once #3021803: Enable autowiring the container and #3021898: Support _defaults key in service.yml files have landed.

Remaining tasks

User interface changes

None

API changes

@todo

Data model changes

None

Release notes snippet

@todo


Viewing all articles
Browse latest Browse all 295724

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>