There is some duplicate code in a couple of places related with computed ids for config entities:

  /**
   * {@inheritdoc}
   */
  public function save() {
    // Build an ID if none is set.
    if (empty($this->id)) {
      $this->id = $this->id();
    }
    return parent::save();
  }

This should be moved to ConfigStorageController::create() (if the id is accessible / not protected) or ConfigEntityBase::preSave

Related: #2020895: Move save() / delete() logic in Field / FieldInstance to [pre|post]Save(), [pre|post]Delete()

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pcambra’s picture

Issue tags: +Field API

Tagging

yched’s picture

Component: field system » configuration entity system
Issue tags: +Configuration system

Moving to config entity

pcambra’s picture

Status: Active » Needs review
Issue tags: -Configuration system
FileSize
3.06 KB

Here's a patch for this.
Initially I wanted to add this in the create method of the storage controller, but then I realized that the clone/duplicate methods don't go through this so I moved it to save().

pcambra’s picture

ehm, retagging, dunno why last comment changed it.

pcambra’s picture

Issue tags: +Field API

Again?

yched’s picture

Status: Needs review » Reviewed & tested by the community

Looks good. Thanks !

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed b44b584 and pushed to 8.x. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.