[6.x] Remove remaining usages of Craft::createObject#18729
Open
[6.x] Remove remaining usages of Craft::createObject#18729
Conversation
There was a problem hiding this comment.
Pull request overview
This PR continues the 6.x migration away from Craft::createObject() by updating remaining instantiation sites to use the Laravel container (app()->make()) or direct construction (new), aligning core/runtime code with the post-Yii instantiation approach.
Changes:
- Replaced
Craft::createObject()calls across controllers, elements, GraphQL, and field layout code withapp()->make()and/ornew. - Updated some GraphQL execution internals (context object construction, exception logging via
report()). - Modernized some GraphQL mutation resolver callables (first-class callables in
Entrymutations).
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| yii2-adapter/legacy/controllers/ElementsController.php | Uses the app container to instantiate element types instead of Craft::createObject(). |
| src/User/Elements/User.php | Removes Craft import; constructs UserCondition directly. |
| src/Twig/Extensions/CoreTwigExtension.php | Switches Twig create() function implementation away from Craft::createObject(). |
| src/Image/ImageTransforms.php | Changes transformer instantiation away from Craft::createObject(). |
| src/Http/Controllers/Settings/FilesystemsController.php | Uses container to instantiate filesystem types. |
| src/Http/Controllers/MatrixController.php | Uses new Entry([...]) instead of Craft::createObject() for entry creation. |
| src/Http/Controllers/Entries/CreateEntryController.php | Uses new Entry for draft creation. |
| src/Gql/Types/Elements/Element.php | Replaces Craft::createObject() with direct instantiation for ArgumentManager. |
| src/Gql/Resolvers/ElementResolver.php | Replaces Craft::createObject() with direct instantiation for query helpers. |
| src/Gql/Mutations/Entry.php | Instantiates resolver directly and uses first-class callables for resolve. |
| src/Gql/Mutations/Asset.php | Instantiates resolver directly (and keeps array callable style in one place). |
| src/Gql/Gql.php | Uses direct instantiation for GQL helpers; switches exception logging to report(); adjusts directive registration logic. |
| src/FieldLayout/FieldLayout.php | Replaces dynamic instantiation with container-based creation; updates CustomField instantiation. |
| src/Entry/Elements/Entry.php | Directly constructs condition object and new entry clones. |
| src/Element/Concerns/Queryable.php | Constructs ElementCondition directly. |
| src/Asset/Elements/Asset.php | Constructs AssetCondition directly. |
| src/Asset/Assets.php | Replaces Craft::createObject() with new ImageTransform([...]). |
| src/Address/Elements/Address.php | Constructs AddressCondition directly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.