Lister::setSource PHP Method

setSource() public method

Similar to setModel, however you specify array of data here. setSource is actually implemented around :php:class:Controller_Data_Array. actually you can pass anything iterateable to setSource() as long as elements of iterating produce either a string or array.
public setSource ( mixed $source, array | string | null $fields = null )
$source mixed
$fields array | string | null
    public function setSource($source, $fields = null)
    {
        // Set DSQL
        if ($source instanceof DB_dsql) {
            $this->dq = $source;
            return $this;
        }
        // SimpleXML and other objects
        if (is_object($source)) {
            if ($source instanceof Model) {
                throw $this->exception('Use setModel() for Models');
            } elseif ($source instanceof Controller) {
                throw $this->exception('Use setController() for Controllers');
            } elseif ($source instanceof Iterator || $source instanceof Closure) {
                $this->iter = $source;
                return $this;
            }
            // Cast non-iterable objects into array
            $source = (array) $source;
        }
        // Set Array as a data source
        if (is_array($source)) {
            $m = $this->setModel('Model', $fields);
            $m->setSource('Array', $source);
            return $this;
        }
        // Set manually
        $this->dq = $this->app->db->dsql();
        $this->dq->table($source)->field($fields ?: '*');
        return $this;
    }