public function prepareViewModel(Datagrid $grid) { //parent::prepareViewModel($grid); $options = $this->getOptionsRenderer(); $data = $grid->getDataSource()->getDataDetail(); $viewModel = $this->getViewModel(); $mcvEvent = $grid->getMvcEvent(); $viewModel->setVariable('daterangeEnabled', false); $action = $mcvEvent->getRouteMatch()->getParam('action'); $routeName = $mcvEvent->getRouteMatch()->getMatchedRouteName(); $controller = $mcvEvent->getRouteMatch()->getParam('controller'); $route = array("routeName" => $routeName, "action" => $action, "controller" => $controller); //var_dump($route); $viewModel->setVariable('main_ruote', $route); $viewModel->setVariable('view_detail', $grid->getDataDetail()); }
public function testDataSourceDoctrineCollection() { $grid = new Datagrid(); $this->assertFalse($grid->hasDataSource()); $coll = $this->getMock('Doctrine\\Common\\Collections\\ArrayCollection', array(), array(), '', false); $em = $this->getMock('Doctrine\\ORM\\EntityManager', array(), array(), '', false); $grid->setDataSource($coll, $em); $this->assertTrue($grid->hasDataSource()); $this->assertInstanceOf('Zf2datatable\\DataSource\\Doctrine2Collection', $grid->getDataSource()); $this->setExpectedException('InvalidArgumentException', 'If providing a Collection, also the Doctrine\\ORM\\EntityManager is needed as a second parameter'); $grid->setDataSource($coll); }