Exemplo n.º 1
0
 /**
  * Factory method to create a part.
  *
  * @param $partId
  * @param $manufacturerId
  * @param $manufacturerName
  * @return Part
  */
 public static function manufacture($partId, $manufacturerId, $manufacturerName)
 {
     $part = new Part();
     // After instantiation of the object we apply the "PartWasManufacturedEvent".
     $part->apply(new PartWasManufacturedEvent($partId, $manufacturerId, $manufacturerName));
     return $part;
 }
 /**
  * A new part aggregate root is created and added to the repository.
  *
  * @param ManufacturePartCommand $command
  */
 protected function handleManufacturePartCommand(ManufacturePartCommand $command)
 {
     $part = Part::manufacture($command->partId, $command->manufacturerId, $command->manufacturerName);
     $this->repository->save($part);
 }