Skip to content

[6.x] Remove remaining usages of Craft::createObject#18729

Open
riasvdv wants to merge 5 commits into6.xfrom
feature/create-object
Open

[6.x] Remove remaining usages of Craft::createObject#18729
riasvdv wants to merge 5 commits into6.xfrom
feature/create-object

Conversation

@riasvdv
Copy link
Copy Markdown
Contributor

@riasvdv riasvdv commented Apr 17, 2026

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with app()->make() and/or new.
  • Updated some GraphQL execution internals (context object construction, exception logging via report()).
  • Modernized some GraphQL mutation resolver callables (first-class callables in Entry mutations).

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.

Comment thread src/Image/ImageTransforms.php
Comment thread src/Twig/Extensions/CoreTwigExtension.php Outdated
Comment thread src/Gql/Gql.php
@riasvdv riasvdv requested a review from brandonkelly April 17, 2026 18:02
@riasvdv riasvdv marked this pull request as ready for review April 17, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants