/** * @param Definition $definition * @param Property $property * @throws InvalidArgumentException */ private function validateAssociation(Definition $definition, Property $property) { if ($property->isAssociated()) { $targetClass = (string) $property->getAssociation()->getTargetClassName(); if (!array_key_exists($targetClass, $this->entityDefinitions)) { throw new InvalidArgumentException(sprintf("Entity class \"%s\" used in association of \"%s\" entity does not have definition.", $targetClass, (string) $definition->getClassName())); } } }
/** * @param Property $property * @param $oldValue * @param $newValue * @return \Isolate\UnitOfWork\Entity\Value\Change\ScalarChange * @throws RuntimeException */ private function buildChange(Property $property, $oldValue, $newValue) { if ($property->isAssociated()) { $association = $property->getAssociation(); switch ($association->getType()) { case Association::TO_SINGLE_ENTITY: return $this->buildAssociationToSingleEntityChange($property, $oldValue, $newValue); case Association::TO_MANY_ENTITIES: return $this->buildAssociationToManyEntitiesChange($property, $oldValue, $newValue); } } return new ScalarChange($property, $oldValue, $newValue); }