Problem/Motivation

The standard install profile has a few call to the (to be) deprecated "entity_create()" function.

As the comment of the function said, it will only be removed in Drupal 9, but we can still clean this right now.

 * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0.0. Use
 *    the <EntityType>::create($values) method if the entity type is known or
 *    \Drupal::entityManager()->getStorage($entity_type)->create($values) if the
 *    entity type is variable.

Proposed resolution

- use the <EntityType>::create($values) method.

Remaining tasks

Just do it.

User interface changes

Nothing.

API changes

Nothing.

Data model changes

Nothing.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because this cleans up code
Issue priority Normal because it is replacing existing code with best practice
Prioritized changes The main goal of this issue is removing code already deprecated for 8.0.0
Disruption None

Comments

haza’s picture

haza’s picture

Issue summary: View changes
dawehner’s picture

Status: Active » Needs review
Issue tags: +Quickfix, +Needs beta evaluation

Let's ask the testbot, but yes, this small adjustments look alright.

haza’s picture

We still do have a lot of call to entity_create() in core

rgrep 'entity_create(' * | wc -l
1012

But I think we should clean that one step at a time.

In core/profile, we only have those 2 :

(cd core/profiles/; rgrep 'entity_create(' *)
standard/standard.install:  $shortcut = entity_create('shortcut', array(
standard/standard.install:  $shortcut = entity_create('shortcut', array(
cilefen’s picture

Title: Small code cleanning for the standard install profile » Remove calls to entity_create() in the standard install profile
Priority: Minor » Normal
longwave’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs beta evaluation
webchick’s picture

Version: 8.0.x-dev » 8.1.x-dev
Status: Reviewed & tested by the community » Postponed

This patch seems fine, but in #2490966: [Meta] Replace deprecated usage of entity_create with a direct call to the entity type class there was a decision to push this initiative off to 8.1.x, so doing the same here.

duaelfr’s picture

According to the meta issue, the replacements now have to be made by entity type and not by location anymore.