Skip to content

Commit

Permalink
Added validators for cascaded inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
rjzondervan committed Nov 11, 2019
1 parent 8c6d8e7 commit bcfe8eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions api/src/Entity/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Property
* @var Object $requestType The requestType that this property belongs to
*
* @Assert\NotBlank
* @Assert\Valid
* @MaxDepth(1)
* @Groups({"read", "write"})
* @ORM\ManyToOne(targetEntity="App\Entity\RequestType", inversedBy="properties",cascade={"persist"})
Expand Down
25 changes: 13 additions & 12 deletions api/src/Entity/RequestType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\Serializer\Annotation\MaxDepth;

/**
* @ApiResource(
* @ApiResource(
* normalizationContext={"groups"={"read"}, "enable_max_depth"=true},
* denormalizationContext={"groups"={"write"}, "enable_max_depth"=true},
* collectionOperations={
Expand All @@ -35,7 +35,7 @@
* "type" : "boolean"
* }
* }
* }
* }
* },
* "put",
* "delete"
Expand Down Expand Up @@ -72,7 +72,7 @@ class RequestType
/**
* @var string $sourceOrganization The RSIN of the organization that owns this process
* @example 002851234
*
*
* @ApiProperty(
* attributes={
* "swagger_context"={
Expand All @@ -83,7 +83,7 @@ class RequestType
* }
* }
* )
*
*
* @Assert\NotNull
* @Assert\Length(
* min = 8,
Expand Down Expand Up @@ -111,7 +111,7 @@ class RequestType
* }
* }
* )
*
*
* @Assert\NotNull
* @Assert\Length(
* max = 255
Expand All @@ -136,7 +136,7 @@ class RequestType
* }
* }
* )
*
*
* @Assert\Length(
* max = 2550
* )
Expand All @@ -149,20 +149,21 @@ class RequestType
* @Groups({"read", "write"})
* @MaxDepth(1)
* @ORM\OneToMany(targetEntity="App\Entity\Property", mappedBy="requestType", orphanRemoval=true, fetch="EAGER", cascade={"persist"})
* @Assert\Valid
*/
private $properties;

/**
* @var object $extends The requestType that this requestType extends
*
*
* @Groups({"write-requesttype"})
* @ORM\ManyToOne(targetEntity="App\Entity\RequestType", inversedBy="extendedBy", fetch="EAGER")
*/
private $extends;

/**
* @var object $extendedBy The requestTypes that extend this requestType
*
*
* @ORM\OneToMany(targetEntity="App\Entity\RequestType", mappedBy="extends")
*/
private $extendedBy;
Expand All @@ -188,11 +189,11 @@ public function getId()
{
return $this->id;
}

public function setId(string $id): self
{
$this->id = $id;

return $this;
}

Expand Down Expand Up @@ -249,7 +250,7 @@ public function addProperty(Property $property): self

return $this;
}

/*
* Used for soft adding properties for the extension functionality
*/
Expand All @@ -258,7 +259,7 @@ public function extendProperty(Property $property): self
if (!$this->properties->contains($property)) {
$this->properties[] = $property;
}

return $this;
}

Expand Down

0 comments on commit bcfe8eb

Please sign in to comment.