Fall back to creating stub entity instead of just returning the plain UUID string when entity doesn't exist during param converting. This would simplify the logic a lot in each resource plugin.

So \Drupal\relaxed\ParamConverter\DbConverter::convert() \Drupal\relaxed\ParamConverter\DocIdConverter::convert() needs to change, so that we don't need all is_string() checks in the resource plugins.

Because things like this loose typing just doesn't make any sense:

  /**
   * @param string | \Drupal\multiversion\Entity\WorkspaceInterface $workspace
   * @param string | \Drupal\Core\Entity\ContentEntityInterface $existing_entity
   * @param \Drupal\Core\Entity\ContentEntityInterface $received_entity
   *
   * @return \Drupal\rest\ResourceResponse
   */
  public function put($workspace, $existing_entity, ContentEntityInterface $received_entity) {
    if (is_string($workspace)) {
      throw new NotFoundHttpException();
    }
    // [...]

Comments

dixon_ created an issue. See original summary.

dixon_’s picture

Issue summary: View changes
dixon_’s picture

Issue summary: View changes
timmillwood’s picture

Assigned: Unassigned » timmillwood

  • timmillwood committed c2cbc72 on 8.x-1.x
    Fall back to stub entity when entity doesn't exist d.o#2600370
    
timmillwood’s picture

Assigned: timmillwood » Unassigned
Status: Active » Needs work

\Drupal\relaxed\ParamConverter\DocIdConverter::convert() still needs updating.

  • jeqq committed a0fc737 on 8.x-1.x
    Merge pull request #61 from relaxedws/DbConverter-fix
    
    Issue #2600370:...
jeqq’s picture

Status: Needs work » Closed (outdated)

This has been fixed a long time ago.