Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Updated: Comment 0
Problem/Motivation
If you first time teach people about routing/local tasks and finally .services.yml files you will get the result that it is harder for people to
understand why they need to specify services:
yml file in these files, even the filename already specify it.
Proposed resolution
Allow to specify services on the root level.
Before:
services:
access_check.permission:
class: Drupal\user\Access\PermissionAccessCheck
tags:
- { name: access_check }
access_check.user.register:
class: Drupal\user\Access\RegisterAccessCheck
tags:
- { name: access_check }
after
access_check.permission:
class: Drupal\user\Access\PermissionAccessCheck
tags:
- { name: access_check }
access_check.user.register:
class: Drupal\user\Access\RegisterAccessCheck
tags:
- { name: access_check }
Remaining tasks
User interface changes
API changes
Related Issues
Comment | File | Size | Author |
---|---|---|---|
#23 | 2139583-23.patch | 956 bytes | dawehner |
#13 | 2139583-13.patch | 110.99 KB | damiankloip |
Comments
Comment #1
dawehnerThis is just a prototype to see whether anything fails hard.
Comment #3
dawehner1: services-2139583.patch queued for re-testing.
Comment #5
dawehner1: services-2139583.patch queued for re-testing.
Comment #6
Crell CreditAttribution: Crell commentedI'm a little bit leery, as this introduces a potential incompatibility with the same file in Symfony; without this patch, the syntax we're using is identical to Symfony's.
OTOH, Symfony fullstack for whatever strange reason tends to use XML files instead of YAML for the services file, so... I'm torn.
Comment #7
dawehnerEveryone who writes a service file by hand will potentially run into this problem, so I consider this critical.
Comment #8
aspilicious CreditAttribution: aspilicious commentedYES experienced thuis several times already smashing my head against the desk. If we do this we should do it before beta.
Comment #9
catchEither needs to block beta or it's not critical, went for beta blocker.
Comment #10
catchActually no, seems good but it's not the end of the world.
Comment #11
damiankloip CreditAttribution: damiankloip commentedRerolled and converted all core services.yml files
Comment #12
dawehnerCreated a drafted change notice: https://drupal.org/node/2197139
Comment #13
damiankloip CreditAttribution: damiankloip commentedReroll.
Comment #14
dawehner13: 2139583-13.patch queued for re-testing.
Comment #15
Crell CreditAttribution: Crell commentedActually I just started working on a demo module for a class where using a parameter for something makes total sense. Let's not sell parameters short.
Also, this would make those files less consistent and more divergent from existing Symfony documentation we don't want to rewrite. I'm overall -1. Really, I've yet to be bothered by the "services" header.
Comment #16
Crell CreditAttribution: Crell commentedAnother thing that just occurred to me: It means if I have a file that has just services with no header, and I want to add a parameter, what would have been a 3 line patch is now a "whole file replace" patch.
Comment #17
damiankloip CreditAttribution: damiankloip commentedMeh, that's kind of a moot point IMO :) You add one line and then tab the existing YAML in the file to indent it. Yes, the diff will be bigger - Who really cares about that though.
Let's also remember, people using parameters on the container in services.yml files is going to be a rarity, rather than the norm.
Comment #18
dawehnerSo? We don't support bundles nor does bundles support modules. Also note this is optional. I would be fine with no changing core at all, but at least remove that sillyness for people when they write custom modules.
This is not true. It will just work as always. You can still indent and put parameters under the parameters key.
Even I don't like that, this statement is probably true.
Comment #19
dawehnerWell, this is optional, noone has to. It is just nicer. Symfony bundles are so different to modules anyway.
Comment #20
damiankloip CreditAttribution: damiankloip commentedYeah, I think this is nicer, plus it is optional. If we have to, we can not convert all of the core services files?
Comment #21
sunI agree with @Crell here.
But instead of just mulling over hypothetical consistency concerns, I disagree with this proposal, because I want to kill the inconsistency, in particular to improve DX:
#2251113: Use container parameters instead of settings
Comment #22
dawehnerWell, in those case we maybe should rename the file to services_parameters.yml
Comment #23
dawehnerAT least we should improve the really unhelpful exception message.
Comment #25
Crell CreditAttribution: Crell commentedI have no idea why testbot doesn't like #23, but I like that approach combined with #2251113: Use container parameters instead of settings a lot better.
Comment #26
damiankloip CreditAttribution: damiankloip commented23: 2139583-23.patch queued for re-testing.
Just checking whether that failure is for reals.
Comment #27
tim.plunkettWell #23 is definitely an improvement over HEAD. But do we really want to cannibalize this issue with that? What about opening a small dedicated issue for that, and leaving this one in case we decide to go with that?
Comment #28
sun#23 makes sense. Though the same fix should be filed as an upstream PR in tandem, because the only reason for why this code even exists as a literal copy is that the
YamlFileLoader
methods are declared as private upstream (which should be a separate PR that I wanted to create last weekend but forgot).Comment #29
dawehnerI don't think we should wait at all on upstream because the code is totally different. They support arbitrary key via their extensions.
Comment #30
sunYeah, I didn't mean to "wait."
FYI, created https://github.com/symfony/symfony/pull/10920 for the method visibility problem, so that we can properly extend this class hopefully soon.
Comment #31
sunThat PR didn't work out, so instead I created:
#2269385: DependencyInjection YamlFileLoader is out of date
Comment #32
catchThat error message doesn't seem like a major task...
Committed/pushed to 8.x, thanks!