public static function fromDomainEvent(DomainEvent $domainEvent) { $dbEvent = new DbEvent(); $dbEvent->setId($domainEvent->getId()); $dbEvent->setTitle($domainEvent->getTitle()); $dbEvent->setDateWithTimeRange(DbDateWithTimeRangeFactory::fromDomainDateWithRimeRange($domainEvent->getScheduledDateWithTimeRange())); return $dbEvent; }
/** * @return Event */ public function getUnScheduledEvent() { $unscheduledEvent = new Event($this->id, $this->title); $this->assertFalse($unscheduledEvent->isScheduled()); $this->assertEquals($this->id, $unscheduledEvent->getId()); $this->assertEquals($this->title, $unscheduledEvent->getTitle()); return $unscheduledEvent; }
/** * @param DbEvent $dbEvent * @return DomainEvent * @throws \CoreDomain\Exception\DomainRuleException */ public static function fromDbEvent(DbEvent $dbEvent) { $domainEvent = new DomainEvent(new UUId($dbEvent->getId()), new String($dbEvent->getTitle())); $dateWithTimeRange = DomainDateWithTimeRangeFactory::fromDateWithTimeRangeEmbeddable($dbEvent->getDateWithTimeRange()); if ($dateWithTimeRange) { $domainEvent->schedule($dateWithTimeRange); } return $domainEvent; }