public function setDataSource($data)
    {
        if ($data instanceof DataSource\DataSourceInterface) {
            $this->dataSource = $data;
        } elseif (is_array($data)) {
            $this->dataSource = new DataSource\PhpArray($data);
        } elseif ($data instanceof QueryBuilder) {
            $this->dataSource = new DataSource\Doctrine2($data);
        } elseif ($data instanceof ZendSelect) {
            $args = func_get_args();
            if (count($args) === 1 ||
                (! $args[1] instanceof \Zend\Db\Adapter\Adapter && ! $args[1] instanceof \Zend\Db\Sql\Sql)
            ) {
                throw new \InvalidArgumentException(
                    'For "Zend\Db\Sql\Select" also a "Zend\Db\Adapter\Sql" or "Zend\Db\Sql\Sql" is needed.'
                );
            }
            $this->dataSource = new DataSource\ZendSelect($data);
            $this->dataSource->setAdapter($args[1]);
        } elseif ($data instanceof Collection) {
            $args = func_get_args();
            if (count($args) === 1 || ! $args[1] instanceof \Doctrine\ORM\EntityManager) {
                throw new \InvalidArgumentException(
                    'If providing a Collection, also the Doctrine\ORM\EntityManager is needed as a second parameter'
                );
            }
            $this->dataSource = new DataSource\Doctrine2Collection($data);
            $this->dataSource->setEntityManager($args[1]);
        } else {
            throw new \InvalidArgumentException(
                '$data must implement the interface ZfcDatagrid\DataSource\DataSourceInterface'
            );
        }
    }
public function setDataSource($data)
    {
        if ($data instanceof DataSource\DataSourceInterface) {
            $this->dataSource = $data;
        } elseif (is_array($data)) {
            $this->dataSource = new DataSource\PhpArray($data);
        } elseif ($data instanceof QueryBuilder) {
            $this->dataSource = new DataSource\Doctrine2($data);
        } elseif ($data instanceof ZendSelect) {
            $args = func_get_args();
            if (count($args) === 1 ||
                (! $args[1] instanceof \Zend\Db\Adapter\Adapter && ! $args[1] instanceof \Zend\Db\Sql\Sql)
            ) {
                throw new \InvalidArgumentException(
                    'For "Zend\Db\Sql\Select" also a "Zend\Db\Adapter\Sql" or "Zend\Db\Sql\Sql" is needed.'
                );
            }
            $this->dataSource = new DataSource\ZendSelect($data);
            $this->dataSource->setAdapter($args[1]);
        } elseif ($data instanceof Collection) {
            $args = func_get_args();
            if (count($args) === 1 || ! $args[1] instanceof \Doctrine\ORM\EntityManager) {
                throw new \InvalidArgumentException(
                    'If providing a Collection, also the Doctrine\ORM\EntityManager is needed as a second parameter'
                );
            }
            $this->dataSource = new DataSource\Doctrine2Collection($data);
            $this->dataSource->setEntityManager($args[1]);
        } else {
            throw new \InvalidArgumentException(
                '$data must implement the interface ZfcDatagrid\DataSource\DataSourceInterface'
            );
        }
    }
public function setDataSource ( $ data ) { if ( $ data instanceof DataSource \ DataSourceInterface ) { $ this -> dataSource = $ data ; } elseif ( is_array ( $ data ) ) { $ this -> dataSource = new DataSource \ PhpArray ( $ data ) ; } elseif ( $ data instanceof QueryBuilder ) { $ this -> dataSource = new DataSource \ Doctrine2 ( $ data ) ; } elseif ( $ data instanceof ZendSelect ) { $ args = func_get_args ( ) ; if ( count ( $ args ) === 1 || ( ! $ args [ 1 ] instanceof \ Zend \ Db \ Adapter \ Adapter && ! $ args [ 1 ] instanceof \ Zend \ Db \ Sql \ Sql ) ) { throw new \ InvalidArgumentException ( 'For "Zend\Db\Sql\Select" also a "Zend\Db\Adapter\Sql" or "Zend\Db\Sql\Sql" is needed.' ) ; } $ this -> dataSource = new DataSource \ ZendSelect ( $ data ) ; $ this -> dataSource -> setAdapter ( $ args [ 1 ] ) ; } elseif ( $ data instanceof Collection ) { $ args = func_get_args ( ) ; if ( count ( $ args ) === 1 || ! $ args [ 1 ] instanceof \ Doctrine \ ORM \ EntityManager ) { throw new \ InvalidArgumentException ( 'If providing a Collection, also the Doctrine\ORM\EntityManager is needed as a second parameter' ) ; } $ this -> dataSource = new DataSource \ Doctrine2Collection ( $ data ) ; $ this -> dataSource -> setEntityManager ( $ args [ 1 ] ) ; } else { throw new \ InvalidArgumentException ( '$data must implement the interface ZfcDatagrid\DataSource\DataSourceInterface' ) ; } }
Set the data source.

@param mixed $data

@throws \Exception
Set the data source .