public function create(ClassType $classType, array $parameters)
 {
     $source = $this->sourceFactory->create($classType);
     //Add constructor method.
     $source->addConstructorMethod($this->definitionFactory->createConstructorMethod($parameters));
     return $source;
 }
 public function create(ClassType $classType, array $parameters)
 {
     $source = $this->sourceFactory->create($classType);
     //Adds Projector as parent.
     $source->addParent(ClassType::create('Broadway\\ReadModel\\Projector'));
     $source->addConstructorMethod($this->definitionFactory->createConstructorMethod($parameters));
     return $source;
 }
 public function it_will_create_source_from_given_class_type_and_constructor_params(ClassSourceFactory $sourceFactory, DefinitionFactory $definitionFactory, ClassType $classType, ImprovedClassSource $classSource, Parameter $parameter1, Parameter $parameter2, ConstructorMethod $constructorMethod, SerializeMethod $serializeMethod, DeserializeMethod $deserializeMethod)
 {
     $sourceFactory->create($classType)->willReturn($classSource);
     $definitionFactory->createConstructorMethod([$parameter1, $parameter2])->shouldBeCalled()->willReturn($constructorMethod);
     $definitionFactory->createSerializeMethod($classSource)->shouldBeCalled()->willReturn($serializeMethod);
     $definitionFactory->createDeserializeMethod($classSource)->shouldBeCalled()->willReturn($deserializeMethod);
     $this->create($classType, [$parameter1, $parameter2])->shouldReturn($classSource);
 }
 public function it_will_create_source_from_given_class_type_and_aggregate_root_id_param(ClassSourceFactory $sourceFactory, DefinitionFactory $definitionFactory, ClassType $classType, ImprovedClassSource $classSource, Parameter $parameter, ClassType $parameterClassType, CreateMethod $createMethod, AggregateRootIdGetterMethod $aggregateRootIdGetterMethod)
 {
     $parameter->getClassType()->willReturn($parameterClassType);
     $sourceFactory->create($classType)->willReturn($classSource);
     $definitionFactory->createBroadwayModelCreateMethod($classType, [$parameter])->shouldBeCalled()->willReturn($createMethod);
     $definitionFactory->createBroadwayModelAggregateRootIdGetterMethod($parameter)->shouldBeCalled()->willReturn($aggregateRootIdGetterMethod);
     $this->create($classType, $parameter)->shouldReturn($classSource);
 }
 public function it_will_create_source_from_given_class_type(ClassSourceFactory $sourceFactory, DefinitionFactory $definitionFactory, ClassType $classType, ImprovedClassSource $classSource, Parameter $parameter, ConstructorMethod $constructorMethod, ToStringMethod $toStringMethod, UuidCreateMethod $uuidCreateMethod)
 {
     $sourceFactory->create($classType)->willReturn($classSource);
     $definitionFactory->createParameter('id', Argument::type(StringType::class))->shouldBeCalled()->willReturn($parameter);
     $definitionFactory->createConstructorMethod([$parameter])->shouldBeCalled()->willReturn($constructorMethod);
     $definitionFactory->createToStringMethod($parameter)->shouldBeCalled()->willReturn($toStringMethod);
     $definitionFactory->createUuidCreateMethod($classType)->shouldBeCalled()->willReturn($uuidCreateMethod);
     $this->create($classType)->shouldReturn($classSource);
 }
 public function create(ClassType $classType, ClassType $modelClassType)
 {
     $source = $this->sourceFactory->create($classType);
     $source->addParent(ClassType::create('Broadway\\EventSourcing\\EventSourcingRepository'));
     $source->addImport(ClassType::create('Broadway\\EventSourcing\\AggregateFactory\\PublicConstructorAggregateFactory'));
     $source->addImport(ClassType::create('Broadway\\EventHandling\\EventBusInterface'));
     $source->addImport(ClassType::create('Broadway\\EventStore\\EventStoreInterface'));
     //Add aggregate root id as property.
     //Add constructor which calls parent constructor method.
     $source->addMethod($this->definitionFactory->createBroadwayModelRepositoryConstructorMethod($modelClassType));
     return $source;
 }
 public function create(ClassType $classType, Parameter $parameter)
 {
     $source = $this->sourceFactory->create($classType);
     $source->addParent(ClassType::create('Broadway\\EventSourcing\\EventSourcedAggregateRoot'));
     //Add aggregate root id as property.
     $source->addProperty($parameter);
     $source->addImport($parameter->getClassType());
     //Add static create() method.
     $source->addMethod($this->definitionFactory->createBroadwayModelCreateMethod($classType, [$parameter]));
     //Add aggregate root id getter.
     $source->addMethod($this->definitionFactory->createBroadwayModelAggregateRootIdGetterMethod($parameter));
     return $source;
 }
 public function create(ClassType $classType)
 {
     $source = $this->sourceFactory->create($classType);
     $param = $this->definitionFactory->createParameter('id', new StringType());
     //Add constructor method.
     $source->addConstructorMethod($this->definitionFactory->createConstructorMethod([$param]));
     //Add __toString() method.
     $source->addMethod($this->definitionFactory->createToStringMethod($param));
     //Add static create() method.
     $source->addMethod($this->definitionFactory->createUuidCreateMethod($classType));
     //Add Ramsey\Uuid\Uuid to imports.
     $source->addImport(ClassType::create('Ramsey\\Uuid\\Uuid'));
     return $source;
 }
 public function create(ClassType $classType, array $parameters)
 {
     $source = $this->sourceFactory->create($classType);
     //Add constructor method.
     $source->addConstructorMethod($this->definitionFactory->createConstructorMethod($parameters));
     //Adds Broadway ReadModelInterface.
     $source->addInterface(InterfaceType::create('Broadway\\ReadModel\\ReadModelInterface'));
     //Adds Broadway SerializableInterface.
     $source->addInterface(InterfaceType::create('Broadway\\Serializer\\SerializableInterface'));
     //Adds serialize() method.
     $source->addMethod($this->definitionFactory->createSerializeMethod($source));
     //Adds static deserialize() method.
     $source->addMethod($this->definitionFactory->createDeserializeMethod($source));
     $source->addMethod($this->definitionFactory->createReadModelIdGetterMethod($parameters[0]));
     return $source;
 }
 public function it_will_create_source_from_given_class_type_and_target_entity(ClassSourceFactory $sourceFactory, DefinitionFactory $definitionFactory, ClassType $classType, ImprovedClassSource $classSource, ClassType $modelClassType, RepositoryConstructorMethod $repositoryConstructorMethod)
 {
     $sourceFactory->create($classType)->willReturn($classSource);
     $definitionFactory->createBroadwayModelRepositoryConstructorMethod($modelClassType)->shouldBeCalled()->willReturn($repositoryConstructorMethod);
     $this->create($classType, $modelClassType)->shouldReturn($classSource);
 }