src/Model/Aggregate/Entity.php
protected function applyEmbeddedEntityEvent(
        EmbeddedEntityEventInterface $embedded_entity_event,
        $auto_commit = true
    ) {
        $attribute_name = $embedded_entity_event->getParentAttributeName();
        $embedded_entity_list = $this->getValue($attribute_name);

        if ($embedded_entity_event instanceof EmbeddedEntityAddedEvent) {
            $embedded_type = $this->getEmbeddedEntityTypeFor(
                $attribute_name,
                $embedded_entity_event->getEmbeddedEntityType()
            );
            $embedded_entity = $embedded_type->createEntity([], $this);
            $embedded_entity_list->push($embedded_entity);
        } elseif ($embedded_entity_event instanceof EmbeddedEntityRemovedEvent) {
            $embedded_entity = $this->getEmbeddedEntityFor(
                $attribute_name,
                $embedded_entity_event->getEmbeddedEntityIdentifier()
            );
            $embedded_entity_list->removeItem($embedded_entity);
            if (!$embedded_entity) {
                error_log(__METHOD__ . " - Embedded entity already was removed.");
                return $embedded_entity_event;
            }
        } elseif ($embedded_entity_event instanceof EmbeddedEntityModifiedEvent) {
            $embedded_entity = $this->getEmbeddedEntityFor(
                $attribute_name,
                $embedded_entity_event->getEmbeddedEntityIdentifier()
            );
            if (!$embedded_entity) {
                throw new RuntimeError(
                    'Unable to resolve embedded-entity for embed-event: ' .
                    json_encode($embedded_entity_event->toArray()) .
                    "\nAR-Id: " . $this->getIdentifier()
                );
            }
            if ($embedded_entity_list->getKey($embedded_entity) !== $embedded_entity_event->getPosition()) {
                $embedded_entity_list->moveTo($embedded_entity_event->getPosition(), $embedded_entity);
            }
        } else {
            throw new RuntimeError('Cannot resolve embedded entity');
        }

        return $embedded_entity->applyEvent($embedded_entity_event, $auto_commit);
    }
protected function applyEmbeddedEntityEvent(
        EmbeddedEntityEventInterface $embedded_entity_event,
        $auto_commit = true
    ) {
        $attribute_name = $embedded_entity_event->getParentAttributeName();
        $embedded_entity_list = $this->getValue($attribute_name);

        if ($embedded_entity_event instanceof EmbeddedEntityAddedEvent) {
            $embedded_type = $this->getEmbeddedEntityTypeFor(
                $attribute_name,
                $embedded_entity_event->getEmbeddedEntityType()
            );
            $embedded_entity = $embedded_type->createEntity([], $this);
            $embedded_entity_list->push($embedded_entity);
        } elseif ($embedded_entity_event instanceof EmbeddedEntityRemovedEvent) {
            $embedded_entity = $this->getEmbeddedEntityFor(
                $attribute_name,
                $embedded_entity_event->getEmbeddedEntityIdentifier()
            );
            $embedded_entity_list->removeItem($embedded_entity);
            if (!$embedded_entity) {
                error_log(__METHOD__ . " - Embedded entity already was removed.");
                return $embedded_entity_event;
            }
        } elseif ($embedded_entity_event instanceof EmbeddedEntityModifiedEvent) {
            $embedded_entity = $this->getEmbeddedEntityFor(
                $attribute_name,
                $embedded_entity_event->getEmbeddedEntityIdentifier()
            );
            if (!$embedded_entity) {
                throw new RuntimeError(
                    'Unable to resolve embedded-entity for embed-event: ' .
                    json_encode($embedded_entity_event->toArray()) .
                    "\nAR-Id: " . $this->getIdentifier()
                );
            }
            if ($embedded_entity_list->getKey($embedded_entity) !== $embedded_entity_event->getPosition()) {
                $embedded_entity_list->moveTo($embedded_entity_event->getPosition(), $embedded_entity);
            }
        } else {
            throw new RuntimeError('Cannot resolve embedded entity');
        }

        return $embedded_entity->applyEvent($embedded_entity_event, $auto_commit);
    }
protected function applyEmbeddedEntityEvent ( EmbeddedEntityEventInterface $ embedded_entity_event , $ auto_commit = true ) { $ attribute_name = $ embedded_entity_event -> getParentAttributeName ( ) ; $ embedded_entity_list = $ this -> getValue ( $ attribute_name ) ; if ( $ embedded_entity_event instanceof EmbeddedEntityAddedEvent ) { $ embedded_type = $ this -> getEmbeddedEntityTypeFor ( $ attribute_name , $ embedded_entity_event -> getEmbeddedEntityType ( ) ) ; $ embedded_entity = $ embedded_type -> createEntity ( [ ] , $ this ) ; $ embedded_entity_list -> push ( $ embedded_entity ) ; } elseif ( $ embedded_entity_event instanceof EmbeddedEntityRemovedEvent ) { $ embedded_entity = $ this -> getEmbeddedEntityFor ( $ attribute_name , $ embedded_entity_event -> getEmbeddedEntityIdentifier ( ) ) ; $ embedded_entity_list -> removeItem ( $ embedded_entity ) ; if ( ! $ embedded_entity ) { error_log ( __METHOD__ . " - Embedded entity already was removed." ) ; return $ embedded_entity_event ; } } elseif ( $ embedded_entity_event instanceof EmbeddedEntityModifiedEvent ) { $ embedded_entity = $ this -> getEmbeddedEntityFor ( $ attribute_name , $ embedded_entity_event -> getEmbeddedEntityIdentifier ( ) ) ; if ( ! $ embedded_entity ) { throw new RuntimeError ( 'Unable to resolve embedded-entity for embed-event: ' . json_encode ( $ embedded_entity_event -> toArray ( ) ) . "\nAR-Id: " . $ this -> getIdentifier ( ) ) ; } if ( $ embedded_entity_list -> getKey ( $ embedded_entity ) !== $ embedded_entity_event -> getPosition ( ) ) { $ embedded_entity_list -> moveTo ( $ embedded_entity_event -> getPosition ( ) , $ embedded_entity ) ; } } else { throw new RuntimeError ( 'Cannot resolve embedded entity' ) ; } return $ embedded_entity -> applyEvent ( $ embedded_entity_event , $ auto_commit ) ; }
Apply the given aggregate-event to it's corresponding aggregate and return the resulting source-event.

@param EmbeddedEntityEventInterface $embedded_entity_event
@param boolean $auto_commit

@return EmbeddedEntityEventInterface
Apply the given aggregate - event to it s corresponding aggregate and return the resulting source - event .