/** * Set the value of [value] column. * * @param string $v new value * @param PropelPDO $con Optional. The database connection to use. * Default is NULL. * @return PropertyValue The current object (for fluent API support) */ public function set($v, PropelPDO $con = null) { $property = $this->getProperty($con); if ($property === null) { throw new Exception('Could not get property definition for property value #' . $this->id . '.'); } $v = PropertyPeer::initValue($v, $property->getType()); return $this->setValue(json_encode($v)); }
/** * Retrieves the most-specific property value for the specified user, domain or account. * * If a user does not have a specific value set, the user's domain is * searched for the value, and if this does not yield anything, the account * will be scanned for the default value. * * @param string $name The property name. * @param Account $account The account defining the properties. * @param Domain $domain Optional. Default is NULL. * @param User $user Optional. Default is NULL. * @param PropelPDO $con Optional. The database connection to use. * Default is NULL. * @return mixed The property value, or NULL if no property is found. * @see getProperty() */ public static function get($name, Account $account, Domain $domain = null, User $user = null, PropelPDO $con = null) { $property = PropertyQuery::create()->filterByAccount($account)->findOneByName($name, $con); if ($property === null) { return null; } $accountId = $account->getId(); $domainId = $domain === null ? null : $domain->getId(); $userId = $user === null ? null : $user->getId(); $values = self::createPropertyValueQuery($accountId, null, null)->findByPropertyId($property->getId(), $con); $result = PropertyPeer::initValue(json_decode($property->getDefaultValue(), true), $property->getType()); foreach ($values as $value) { $valueUserId = $value->getUserId(); if ($valueUserId !== null and $valueUserId === $userId) { return $value->get($con); } elseif ($valueUserId !== null) { continue; } elseif ($value->getDomainId() === $domainId and $domainId !== null) { $result = $value->get($con); } } return $result; }