lazyrecord\schema\RuntimeColumn::display PHP Method

display() public method

public display ( $value )
    public function display($value)
    {
        if ($this->validPairs && isset($this->validPairs[$value])) {
            return $this->validPairs[$value];
        }
        if ($this->validValues && ($validValues = Utils::evaluate($this->validValues))) {
            // search value in validValues array
            // because we store the validValues in an (label => value) array.
            if (ArrayUtils::is_assoc_array($validValues)) {
                if (false !== ($label = array_search($value, $validValues))) {
                    return $label;
                }
                return;
            } elseif (in_array($value, $validValues)) {
                return $value;
            }
        }
        // Optional Values
        if ($this->optionValues && ($optionValues = Utils::evaluate($this->optionValues))) {
            // search value in validValues array
            // because we store the validValues in an (label => value) array.
            if (ArrayUtils::is_assoc_array($optionValues)) {
                if (false !== ($label = array_search($value, $optionValues))) {
                    return $label;
                }
                return $value;
            } elseif (in_array($value, $optionValues)) {
                return $value;
            }
            return $value;
        }
        // backward compatible method
        if ($this->validValueBuilder && ($values = call_user_func($this->validValueBuilder))) {
            if (ArrayUtils::is_assoc_array($values)) {
                if (false !== ($label = array_search($value, $values))) {
                    return $label;
                }
                return;
            } elseif (in_array($value, $values)) {
                return $value;
            }
        }
        if ($this->isa == 'bool') {
            return $value ? _('Yes') : _('No');
        }
        if ($value) {
            if (is_string($value)) {
                return _($value);
            } elseif ($value instanceof DateTime) {
                return $value->format(DateTime::ATOM);
            }
        }
        return $value;
    }