Prooph\EventStore\Aggregate\AggregateType::fromAggregateRootClass PHP 메소드

fromAggregateRootClass() 공개 정적인 메소드

Use this factory when aggregate type equals to aggregate root class The factory makes sure that the aggregate root class exists.
public static fromAggregateRootClass ( string $aggregateRootClass ) : AggregateType
$aggregateRootClass string
리턴 AggregateType
    public static function fromAggregateRootClass($aggregateRootClass)
    {
        if (!is_string($aggregateRootClass)) {
            throw new Exception\InvalidArgumentException('Aggregate root class must be a string');
        }
        if (!class_exists($aggregateRootClass)) {
            throw new Exception\InvalidArgumentException(sprintf('Aggregate root class %s can not be found', $aggregateRootClass));
        }
        return new static($aggregateRootClass);
    }

Usage Example

예제 #1
0
 protected function setUp()
 {
     parent::setUp();
     $this->repository = new AggregateRepository($this->eventStore, AggregateType::fromAggregateRootClass('Prooph\\EventStoreTest\\Mock\\User'), new ConfigurableAggregateTranslator());
     $this->eventStore->beginTransaction();
     $this->eventStore->create(new Stream(new StreamName('event_stream'), []));
     $this->eventStore->commit();
 }
All Usage Examples Of Prooph\EventStore\Aggregate\AggregateType::fromAggregateRootClass