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()

Files: 
CommentFileSizeAuthor
#3 2054699-config_entity_composite_id-3.patch3.06 KBpcambra
PASSED: [[SimpleTest]]: [MySQL] 57,781 pass(es). View

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
PASSED: [[SimpleTest]]: [MySQL] 57,781 pass(es). View

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.