예제 #1
0
 public function testSetDataHandlerMappings()
 {
     $request = m::mock('Cartalyst\\DataGrid\\RequestProviders\\ProviderInterface');
     $mappings = ['Cartalyst\\DataGrid\\DataHandlers\\CollectionHandler', function ($data) {
         return $data instanceof Collection or is_array($data);
     }];
     $environment = new Environment($request);
     $environment->setDataHandlerMappings($mappings);
     $this->assertSame($mappings, $environment->getDataHandlerMappings());
 }
예제 #2
0
 /**
  * Sets a data handler mapping.
  *
  * @param string $class
  * @param \Closure $handler
  * @return void 
  * @static 
  */
 public static function setDataHandlerMapping($class, $handler)
 {
     \Cartalyst\DataGrid\Environment::setDataHandlerMapping($class, $handler);
 }
예제 #3
0
 /**
  * Returns the instance as an array.
  *
  * @return array
  */
 public function toArray()
 {
     $handler = $this->dataHandler;
     $requestProvider = $this->env->getRequestProvider();
     return array('total' => $handler->getTotalCount(), 'filtered' => $handler->getFilteredCount(), 'throttle' => $requestProvider->getThrottle(), 'threshold' => $requestProvider->getThreshold(), 'page' => $handler->getPage(), 'pages' => $handler->getPagesCount(), 'previous_page' => $handler->getPreviousPage(), 'next_page' => $handler->getNextPage(), 'per_page' => $handler->getPerPage(), 'sort' => $handler->getSort(), 'direction' => $handler->getDirection(), 'default_column' => $handler->getDefaultColumn(), 'results' => $handler->getResults());
 }