/** * Returns a PropertyValue object for the specified base object (User, Domain or Account) * * @param User|Domain|Account $obj The reference object * @throws Exception * @return PropertyValue */ private function getValueObject($obj) { $query = PropertyValueQuery::create(); if ($obj instanceof User) { $query->filterByUser($obj); } elseif ($obj instanceof Domain) { $query->filterByDomain($obj); } elseif ($obj instanceof Account) { $query->filterByAccount($obj); } else { throw new Exception('Invalid base object applied. User, Domain or Account expected!'); } $property_value = $query->findOneByProperty($this); if (!$property_value) { $property_value = new PropertyValue(); $property_value->setProperty($this); if ($obj instanceof User) { $property_value->setUser($obj); } elseif ($obj instanceof Domain) { $property_value->setDomain($obj); } elseif ($obj instanceof Account) { $property_value->setAccount($obj); } } return $property_value; }
/** * @param PropertyValue $propertyValue The propertyValue object to add. */ protected function doAddPropertyValue($propertyValue) { $this->collPropertyValues[] = $propertyValue; $propertyValue->setDomain($this); }