- API-platform:
- Separate Resource Entity (Read/Write model DTO; Decouple Model Entity from API-Platform)
- Write:
- Field (property) -> Command
- Only changed fields
- Detect related fields (field1, field2 -> Command; handle interconnected requirements)
- BoolOperation(true=command1, false=command2)
- Commands -> TransactionalCommand (Command1, Command2) -> Handler dispatches back CommandBus (same transaction)
- Only changed fields
- method to convert DTO Create/Delete command
- Handle child entities?
- For a collection all items must be present, any items omitted are removed this works similar to handling a Fork operation.
- Field (property) -> Command
/**
* @var string The name of the item.
*
* @Assert\Type(type="string")
* @Assert\NotNull
* @Domain\Command("CommandName", "argument-name")
*/
private $firsName;
/**
* @var string The name of the item.
*
* @Assert\Type(type="string")
* @Assert\NotNull
*
* If command-name is already queued the argument-name is added to the Command constructor,
* to dispatch the command as one operation.
*
* @Domain\Command("CommandName", "argument-name")
*/
private $lastName;
/**
* @var bool The name of the item.
*
* @Assert\Type(type="bool")
* @Domain\BoolCommand("OnTrueCommandName", "OnFalseCommandName")
*/
private $enabled;
/**
* One generator type allowed (all shown for details)
*
* @Assert\NotNull
* @Domain\IdGenerator(
* method="method on this class",
* service="generator-service"
* class="StandardizedIdClass::generate" # default method name
* class="StandardizedIdClass::customMethodName"
* )
*/
private $id;
public function toCreateCommand()
{
return new RegisterUser($this->id, );
}
Example with child (collection) items:
/**
* @var string The name of the item.
*
* @Assert\Type(type="string")
* @Assert\NotNull
* @Domain\Command("CommandName", "argument-name")
*/
private $firsName;
/**
* @var string The name of the item.
*
* @Assert\Type(type="string")
* @Assert\NotNull
*
* If command-name is already queued the argument-name is added to the Command constructor,
* to dispatch the command as one operation.
*
* @Domain\Command("CommandName", "argument-name")
*/
private $lastName;
/**
* @var bool The name of the item.
*
* @Assert\Type(type="bool")
* @Domain\BoolCommand("OnTrueCommandName", "OnFalseCommandName")
*/
private $enabled;
/**
* One generator type allowed (all shown for details)
*
* @Assert\NotNull
* @Domain\IdGenerator(
* method="method on this class",
* service="generator-service"
* class="StandardizedIdClass::generate" # default method name
* class="StandardizedIdClass::customMethodName"
* )
*/
private $id;
public function toCreateCommand()
{
return new RegisterUser($this->id, );
}