Implemented can_addvalue

This commit is contained in:
Deon George 2023-03-02 14:55:06 +11:00
parent c0c9a5576e
commit 7d19b89637

View File

@ -35,13 +35,11 @@ class Attribute
protected Collection $required_by; protected Collection $required_by;
// MIN/MAX number of values
protected int $min_values_count = 0;
protected int $max_values_count = 0;
/* /*
protected $oldvalues = array();
# MIN/MAX number of values
protected $min_value_count = -1;
protected $max_value_count = -1;
# Has the attribute been modified # Has the attribute been modified
protected $modified = false; protected $modified = false;
# Is the attribute being deleted because of an object class removal # Is the attribute being deleted because of an object class removal
@ -118,7 +116,7 @@ class Attribute
{ {
return match ($key) { return match ($key) {
// Can this attribute have more values // Can this attribute have more values
'can_addvalues' => FALSE, // @todo 'can_addvalues' => $this->schema && (! $this->schema->is_single_value) && ((! $this->max_values_count) || ($this->values->count() < $this->max_values_count)),
// Schema attribute description // Schema attribute description
'description' => $this->schema ? $this->schema->{$key} : NULL, 'description' => $this->schema ? $this->schema->{$key} : NULL,
// Attribute hints // Attribute hints
@ -341,64 +339,6 @@ class Attribute
} }
} }
public function getValue($i) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
if (isset($this->values[$i]))
return $this->values[$i];
else
return null;
}
public function getOldValue($i) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
if (isset($this->oldvalues[$i]))
return $this->oldvalues[$i];
else
return null;
}
public function getMinValueCount() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->min_value_count);
return $this->min_value_count;
}
public function setMinValueCount($min) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs);
$this->min_value_count = $min;
}
public function getMaxValueCount() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->max_value_count);
return $this->max_value_count;
}
public function setMaxValueCount($max) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs);
$this->max_value_count = $max;
}
public function haveMoreValues() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
if ($this->getMaxValueCount() < 0 || ($this->getValueCount() < $this->getMaxValueCount()))
return true;
else
return false;
}
public function justModified() { public function justModified() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);