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()); }
/** * 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); }
/** * 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()); }