PodsUI::get_data PHP Method

get_data() public method

public get_data ( $params = null ) : boolean
return boolean
    public function get_data($params = null)
    {
        $action = $this->action;
        $defaults = array('full' => false, 'flatten' => true, 'fields' => null, 'type' => '');
        if (!empty($params) && is_array($params)) {
            $params = (object) array_merge($defaults, $params);
        } else {
            $params = (object) $defaults;
        }
        if (!in_array($action, array('manage', 'reorder'))) {
            $action = 'manage';
        }
        $find_params = $this->get_params($params);
        if (false !== $this->pod && is_object($this->pod) && ('Pods' == get_class($this->pod) || 'Pod' == get_class($this->pod))) {
            $this->pod->find($find_params);
            if (!$params->full) {
                $data = $this->pod->data();
                $this->data = $data;
                if (!empty($this->data)) {
                    $this->data_keys = array_keys($this->data);
                }
                $this->total = $this->pod->total();
                $this->total_found = $this->pod->total_found();
            } else {
                $this->data_full = array();
                $export_params = array('fields' => $params->fields, 'flatten' => true);
                if (in_array($params->type, array('json', 'xml'))) {
                    $export_params['flatten'] = false;
                }
                $export_params = $this->do_hook('export_options', $export_params, $params);
                while ($this->pod->fetch()) {
                    $this->data_full[$this->pod->id()] = $this->pod->export($export_params);
                }
                $this->pod->reset();
                return $this->data_full;
            }
        } else {
            if (!empty($this->data)) {
                return $this->data;
            }
            if (empty($this->sql['table'])) {
                return $this->data;
            }
            $this->pods_data->select($find_params);
            if (!$params->full) {
                $this->data = $this->pods_data->data;
                if (!empty($this->data)) {
                    $this->data_keys = array_keys($this->data);
                }
                $this->total = $this->pods_data->total();
                $this->total_found = $this->pods_data->total_found();
            } else {
                $this->data_full = $this->pods_data->data;
                if (!empty($this->data_full)) {
                    $this->data_keys = array_keys($this->data_full);
                }
                return $this->data_full;
            }
        }
        return $this->data;
    }