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