Pods::__construct PHP 메소드

__construct() 공개 메소드

Constructor - Pods Framework core
부터: 1.0.0
public __construct ( string $pod = null, mixed $id = null ) : Pods
$pod string The pod name
$id mixed (optional) The ID or slug, to load a single record; Provide array of $params to run 'find'
리턴 Pods
    public function __construct($pod = null, $id = null)
    {
        if (null === $pod) {
            $queried_object = get_queried_object();
            if ($queried_object) {
                $id_lookup = true;
                // Post Type Singular
                if (isset($queried_object->post_type)) {
                    $pod = $queried_object->post_type;
                } elseif (isset($queried_object->taxonomy)) {
                    $pod = $queried_object->taxonomy;
                } elseif (isset($queried_object->user_login)) {
                    $pod = 'user';
                } elseif (isset($queried_object->public) && isset($queried_object->name)) {
                    $pod = $queried_object->name;
                    $id_lookup = false;
                }
                if (null === $id && $id_lookup) {
                    $id = get_queried_object_id();
                }
            }
        }
        $this->api = pods_api($pod);
        $this->api->display_errors =& $this->display_errors;
        $this->data = pods_data($this->api, $id, false);
        PodsData::$display_errors =& $this->display_errors;
        // Set up page variable
        if (pods_strict(false)) {
            $this->page = 1;
            $this->pagination = false;
            $this->search = false;
        } else {
            // Get the page variable
            $this->page = pods_var($this->page_var, 'get');
            $this->page = empty($this->page) ? 1 : max(pods_absint($this->page), 1);
        }
        // Set default pagination handling to on/off
        if (defined('PODS_GLOBAL_POD_PAGINATION')) {
            if (!PODS_GLOBAL_POD_PAGINATION) {
                $this->page = 1;
                $this->pagination = false;
            } else {
                $this->pagination = true;
            }
        }
        // Set default search to on/off
        if (defined('PODS_GLOBAL_POD_SEARCH')) {
            if (PODS_GLOBAL_POD_SEARCH) {
                $this->search = true;
            } else {
                $this->search = false;
            }
        }
        // Set default search mode
        $allowed_search_modes = array('int', 'text', 'text_like');
        if (defined('PODS_GLOBAL_POD_SEARCH_MODE') && in_array(PODS_GLOBAL_POD_SEARCH_MODE, $allowed_search_modes)) {
            $this->search_mode = PODS_GLOBAL_POD_SEARCH_MODE;
        }
        // Sync Settings
        $this->data->page =& $this->page;
        $this->data->limit =& $this->limit;
        $this->data->pagination =& $this->pagination;
        $this->data->search =& $this->search;
        $this->data->search_mode =& $this->search_mode;
        // Sync Pod Data
        $this->api->pod_data =& $this->data->pod_data;
        $this->pod_data =& $this->api->pod_data;
        $this->api->pod_id =& $this->data->pod_id;
        $this->pod_id =& $this->api->pod_id;
        $this->datatype_id =& $this->pod_id;
        $this->api->pod =& $this->data->pod;
        $this->pod =& $this->api->pod;
        $this->datatype =& $this->pod;
        $this->api->fields =& $this->data->fields;
        $this->fields =& $this->api->fields;
        $this->detail_page =& $this->data->detail_page;
        $this->id =& $this->data->id;
        $this->row =& $this->data->row;
        $this->rows =& $this->data->data;
        $this->row_number =& $this->data->row_number;
        $this->sql =& $this->data->sql;
        if (is_array($id) || is_object($id)) {
            $this->find($id);
        }
    }