Bluz\Grid\Source\ArraySource::setSource PHP Method

setSource() public method

Set array source
public setSource ( array $source ) : self
$source array
return self
    public function setSource($source)
    {
        if (!is_array($source) && !$source instanceof \ArrayAccess) {
            throw new Grid\GridException("Source of `ArraySource` should be array or implement ArrayAccess interface");
        }
        $this->source = $source;
        return $this;
    }

Usage Example

Example #1
0
 /**
  * Init ArraySource
  * @return self
  */
 public function init()
 {
     // Array
     $adapter = new ArraySource();
     $adapter->setSource([['id' => 1, 'name' => 'Foo', 'email' => '*****@*****.**', 'status' => 'active'], ['id' => 2, 'name' => 'Bar', 'email' => '*****@*****.**', 'status' => 'active'], ['id' => 3, 'name' => 'Foo 2', 'email' => '*****@*****.**', 'status' => 'disable'], ['id' => 4, 'name' => 'Foo 3', 'email' => '*****@*****.**', 'status' => 'disable'], ['id' => 5, 'name' => 'Foo 4', 'email' => '*****@*****.**', 'status' => 'disable'], ['id' => 6, 'name' => 'Foo 5', 'email' => '*****@*****.**', 'status' => 'disable'], ['id' => 7, 'name' => 'Foo 6', 'email' => '*****@*****.**', 'status' => 'disable'], ['id' => 8, 'name' => 'Foo 7', 'email' => '*****@*****.**', 'status' => 'disable'], ['id' => 9, 'name' => 'Foo 8', 'email' => '*****@*****.**', 'status' => 'disable'], ['id' => 10, 'name' => 'Foo 9', 'email' => '*****@*****.**', 'status' => 'disable']]);
     $this->setAdapter($adapter);
     $this->setDefaultLimit(4);
     $this->setAllowOrders(['name', 'email', 'id']);
     $this->setAllowFilters(['name', 'email', 'status', 'id']);
     return $this;
 }
All Usage Examples Of Bluz\Grid\Source\ArraySource::setSource