Skip to content

Commit

Permalink
Remove unnecessary id assignment in ExampleController
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasnatter committed Mar 3, 2020
1 parent 6f83ad0 commit 16c7f38
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function getAction(Request $request, int $id): Response
$dimensionAttributes = $this->getDimensionAttributes($request);
$contentProjection = $this->contentManager->resolve($example, $dimensionAttributes);

return $this->handleView($this->view($this->resolve($example, $contentProjection)));
return $this->handleView($this->view($this->resolve($contentProjection)));
}

/**
Expand Down Expand Up @@ -146,7 +146,7 @@ public function postAction(Request $request): Response
$this->entityManager->flush();
}

return $this->handleView($this->view($this->resolve($example, $contentProjection), 201));
return $this->handleView($this->view($this->resolve($contentProjection), 201));
}

/**
Expand Down Expand Up @@ -176,7 +176,7 @@ public function postTriggerAction(string $id, Request $request): Response
);
$this->entityManager->flush();

return $this->handleView($this->view($this->resolve($example, $contentProjection)));
return $this->handleView($this->view($this->resolve($contentProjection)));
case 'remove-draft':
$contentProjection = $this->contentManager->applyTransition(
$example,
Expand All @@ -185,7 +185,7 @@ public function postTriggerAction(string $id, Request $request): Response
);
$this->entityManager->flush();

return $this->handleView($this->view($this->resolve($example, $contentProjection)));
return $this->handleView($this->view($this->resolve($contentProjection)));
default:
throw new RestException('Unrecognized action: ' . $action);
}
Expand Down Expand Up @@ -228,7 +228,7 @@ public function putAction(Request $request, int $id): Response
$this->entityManager->flush();
}

return $this->handleView($this->view($this->resolve($example, $contentProjection)));
return $this->handleView($this->view($this->resolve($contentProjection)));
}

/**
Expand Down Expand Up @@ -271,14 +271,10 @@ protected function getData(Request $request): array
*
* @return mixed[]
*/
protected function resolve(Example $example, ContentProjectionInterface $contentProjection): array
protected function resolve(ContentProjectionInterface $contentProjection): array
{
$resolvedData = $this->contentManager->normalize($contentProjection);

// If used autoincrement ids the id need to be set here on
// the resolvedData else on create no id will be returned
$resolvedData['id'] = $example->getId();

return $resolvedData;
}
}

0 comments on commit 16c7f38

Please sign in to comment.