Chumper\Datatable\Table::setCallbacks PHP Method

setCallbacks() public method

public setCallbacks ( )
    public function setCallbacks()
    {
        if (func_num_args() == 2) {
            $this->callbacks[func_get_arg(0)] = func_get_arg(1);
        } else {
            if (func_num_args() == 1 && is_array(func_get_arg(0))) {
                foreach (func_get_arg(0) as $key => $value) {
                    $this->callbacks[$key] = $value;
                }
            } else {
                throw new Exception('Invalid number of callbacks provided for the method "setCallbacks"');
            }
        }
        return $this;
    }

Usage Example

Beispiel #1
0
 /**
  * @expectedException Exception
  */
 public function testSetCallbacks()
 {
     $this->table->setCallbacks('foo', 'bar');
     $this->assertArrayHasKey('foo', $this->table->getCallbacks());
     $this->table->setCallbacks(array('foo2' => 'bar2', 'foo3' => 'bar3'));
     $this->assertArrayHasKey('foo2', $this->table->getCallbacks());
     $this->assertArrayHasKey('foo3', $this->table->getCallbacks());
     $this->table->setCallbacks('foo', 'bar', 'baz');
     $this->assertTrue(False);
     // should throw exception before here
 }
All Usage Examples Of Chumper\Datatable\Table::setCallbacks