Properly use dependency injection and services

Created on 14 March 2016, over 8 years ago
Updated 30 December 2023, 11 months ago

Follow-up to #2490966: [Meta] Replace deprecated usage of entity_create with a direct call to the entity type class

entity_create() function is going to be deprecated so we shouldn't use it anymore. When the entity type is known we should directly call ::create().

Proposed resolution

Replace the deprecated call to entity_create() by a proper call to ::create().

Before:

entity_create('file', $field_values)->save();

After:

use Drupal\file\Entity\File;
File::create($field_values)->save();
📌 Task
Status

Closed: outdated

Version

1.0

Component

Code

Created by

🇮🇳India Purnachandra Rao V

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024