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.
- Remove
ResourceConfigInterface
Rename— handled in #2841287: Remove ResourceManager::hasBundle(), ResourceManager::getEntityTypeManager(), ResourceConfig::getPath(), and rename ResourceConfig::getBundleId()ResourceConfig::getBundleId()
toResourceConfig::bundle()
(for consistency withEntityInterface::bundle()
and everything else in core)- Remove
ResourceManagerInterface
- Mark
ResourceManager
@internal
- Rename
ResourceConfig
toResourceType
andResourceManager
toResourceTypeRepository
(consistent with the rest of core, see #6) - Remove
CurrentContext::getResourceManager()
(see #9) - Rename
CurrentContext::getResourceConfig()
toCurrentContext::getResourceType()
(see #11). - Rename
RelationShipItem::getTargetResourceConfig()
toRelationShipItem::getTargetResourceType()
(see #12)
You can see these steps gradually being applied in the interdiffs for the patches below.
Finally: why do steps 1-4 here and then also do steps 5 and onwards in the same patch? Because they touch the exact same lines, and are very closely related.
Comment | File | Size | Author |
---|---|---|---|
#31 | jsonapi_rename_resource_config-2841296-31.patch | 100.64 KB | Wim Leers |
|
Comments
Comment #2
Wim LeersBlocked on #2841287: Remove ResourceManager::hasBundle(), ResourceManager::getEntityTypeManager(), ResourceConfig::getPath(), and rename ResourceConfig::getBundleId(), which is itself blocked on #2841056: Remove use of plugins.
Comment #3
Wim LeersThis patch does exactly what is outlined in the IS.
Comment #4
Wim Leers#2841287: Remove ResourceManager::hasBundle(), ResourceManager::getEntityTypeManager(), ResourceConfig::getPath(), and rename ResourceConfig::getBundleId() is now already doing the second point in the IS. So, updating the IS and rerolling the patch.
Comment #5
Wim LeersI hadn't actually removed
ResourceConfigInterface
yet (point 1 in the IS). This does that.Comment #6
Wim LeersI renamed
ResourceConfig
toResourceType
andResourceManager
toResourceTypeRepository
:Why "repository"? This is consistent with
EntityRepository
andBlockRepository
.Why "resource type"? Because this is not configuration, but just a mere value object representing a JSON API resource type.
Comment #7
Wim Leers#6 already renamed some occurrences of
resource_manager
andresourceManager
toresource_type_repository
andresourceTypeRepository
. This updates the remainder.Comment #8
Wim LeersSimilar to #7: this renames all occurrences of
$resource_config
to$resource_type
and occurrences of$this->resourceConfig
to$this->resourceType
.Comment #9
Wim LeersI noticed that I'd failed to update
CurrentContext::getResourceManager
consistently. Turns out that that is actually completely unnecessary. OnlyEntityNormalizer
uses it… and it should instead just get the resource manager (now resource type repository) injected. We shouldn't use the "current context" as a secondary container.So, this removes that method altogether.
(This change could be moved to a separate issue that would block this issue if that's preferred.)
Comment #10
Wim LeersIn one of the above patches, I cleaned up
ResourceTypeRepository
in a way that broke things. This fixes it.Comment #11
Wim LeersRename
CurrentContext::getResourceConfig()
toCurrentContext::getResourceType()
.Comment #12
Wim LeersRename
RelationShipItem::getTargetResourceConfig()
toRelationShipItem::getTargetResourceType()
.Comment #13
e0ipsoIn a pre-review i noticed that there are still multiple instances of
'resource_config'
and$resource_config
. I think that we should also rename the variable names and array keys to be consistent.Comment #14
Wim LeersYep, I was still working on that at the end of my day. I will finish this tomorrow :)
If that's the only major remark you have, then that's awesome :D But I suspect you'll have more feedback :)
Comment #15
Wim LeersFinally, made all comments consistent.
Comment #16
Wim LeersNext up: #13 + #14. Also, #2841056: Remove use of plugins landed, so just PP-1 now.
Also, while working on #15, I also wanted to do this:
i.e. I wanted to remove that
protected $resourceTypeRepository
, because it's not actually used — it can just be used in the constructor and then call it a day. Unfortunately, there's a bug in core that gets in the way: #2841542: \Drupal\serialization\EventSubscriber\UserRouteAlterSubscriber has serializer service injected, but doesn't use it — also makes route rebuilding more expensive.(Although, to be fair, the real problem here is that JSON API's normalizers depend on the current request/route match — the Symfony serialization system is designed to be independent of requests. Improving that is for another issue.)
Comment #17
Wim LeersThis then does #13 + #14.
Comment #18
Wim LeersAnd now this is ready!
Comment #19
Wim LeersThis is blocking #2841591: Remove EntityResource, move its logic into RequestHandler, clean up routes.
Comment #20
e0ipsoComment #21
e0ipsoComment #23
e0ipsoThis was a big patch to go through. Good thing that I can see the changes better in PhpStorm.
Some thoughts.
Good catch.
I'm missing here:
Can these two be dropped?
Can we drop Drupal\Core\Config\ConfigFactoryInterface and Drupal\Core\Extension\ModuleHandlerInterface?
Love the extra docs.
Typo
Resourcetype
toResourceType
Comment #24
e0ipsoThis is a BIG patch, but it does not do anything beyond the renaming and dropping some unused stuff.
Good work!
Comment #25
Wim Leers2. That's already in the base class :) Not my idea, it was already there!
3+4. There are quite a few unused
use
statements in various places in the codebase, so I didn't play too close attention. You can remove them on commit, or we can just fix it in a big "coding standards cleanup" patch that we will need to do anyway before this can get into core. :)1+5. :)
6. Hah, nice catch!
I take you're also convinced of the new names I'm suggesting here?
Comment #26
e0ipsoI don't really mind all that much about the names. The new names are good and have some thought and rationale behind them, so I'm on board. You did this patch, that tells me that you do mind therefor I'm up to it.
Comment #27
Wim LeersFirst, rebasing, because #2840948: Remove interfaces of JSON API-specific normalizers was committed too, which caused this to no longer apply.
(This is equivalent to the patch in #17.)
Comment #28
Wim LeersFixed all points (3+4+6) in #23.
Comment #31
Wim LeersLOL, a single typo was causing all those fails AFAICT! Didn't notice locally (everything passes locally), because I'm on a case-insensitive file system!
Comment #33
e0ipsoComment #34
Wim LeersWOOOOOT!