yii\base\ArrayableTrait::resolveFields PHP 메소드

resolveFields() 보호된 메소드

This method will check the requested fields against those declared in ArrayableTrait::fields and ArrayableTrait::extraFields to determine which fields can be returned.
protected resolveFields ( array $fields, array $expand ) : array
$fields array the fields being requested for exporting
$expand array the additional fields being requested for exporting
리턴 array the list of fields to be exported. The array keys are the field names, and the array values are the corresponding object property names or PHP callables returning the field values.
    protected function resolveFields(array $fields, array $expand)
    {
        $result = [];
        foreach ($this->fields() as $field => $definition) {
            if (is_int($field)) {
                $field = $definition;
            }
            if (empty($fields) || in_array($field, $fields, true)) {
                $result[$field] = $definition;
            }
        }
        if (empty($expand)) {
            return $result;
        }
        foreach ($this->extraFields() as $field => $definition) {
            if (is_int($field)) {
                $field = $definition;
            }
            if (in_array($field, $expand, true)) {
                $result[$field] = $definition;
            }
        }
        return $result;
    }