Commit 4b293d1f authored by François Agneray's avatar François Agneray
Browse files

Fixed bug: criteria et output

parent c8d6d929
......@@ -42,7 +42,7 @@ final class AttributeAction
return $response->withHeader('Access-Control-Allow-Methods', 'GET, PUT, OPTIONS');
}
$attribute = $this->em->getRepository('App\Entity\Attribute')->findBy(array('dataset' => $args['name'], 'id' => $args['id']));
$attribute = $this->em->getRepository('App\Entity\Attribute')->findOneBy(array('dataset' => $args['name'], 'id' => $args['id']));
if (is_null($attribute)) {
return $this->dispatchHttpError(
......@@ -58,8 +58,8 @@ final class AttributeAction
if ($request->isPut()) {
$parsedBody = $request->getParsedBody();
$criteriaFamily = $this->em->find('App\Entity\CriteriaFamily', $parsedBody['id_criteria_family']);
$outputCategory = $this->em->find('App\Entity\OutputCategory', $parsedBody['id_output_category']);
$criteriaFamily = is_null($parsedBody['id_criteria_family']) ? null : $this->em->find('App\Entity\CriteriaFamily', $parsedBody['id_criteria_family']);
$outputCategory = is_null($parsedBody['id_output_category']) ? null : $this->em->find('App\Entity\OutputCategory', $parsedBody['id_output_category']);
$this->editAttribute($attribute, $parsedBody, $criteriaFamily, $outputCategory);
$this->em->flush();
......@@ -70,7 +70,7 @@ final class AttributeAction
return $newResponse;
}
private function editAttribute(Attribute $attribute, array $parsedBody, CriteriaFamily $criteriaFamily, OutputCategory $outputCategory): void
private function editAttribute(Attribute $attribute, array $parsedBody, CriteriaFamily $criteriaFamily = null, OutputCategory $outputCategory = null): void
{
$attribute->setLabel($parsedBody['label']);
$attribute->setFormLabel($parsedBody['form_label']);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment