/** * Launch the quick export * * @return Response */ public function indexAction() { $displayedColumnsOnly = (bool) $this->request->get('_displayedColumnsOnly'); $jobCode = $this->request->get('_jobCode'); $jobInstance = $this->jobInstanceRepo->findOneByIdentifier(['code' => $jobCode]); if (null === $jobInstance) { throw new \RuntimeException(sprintf('Jobinstance "%s" is not well configured', $jobCode)); } $filters = $this->gridFilterAdapter->adapt($this->request); $rawParameters = $jobInstance->getRawParameters(); $contextParameters = $this->getContextParameters(); $rawParameters['filePath'] = $this->buildFilePath($rawParameters['filePath'], $contextParameters); $dynamicConfiguration = $contextParameters + ['filters' => $filters]; if ($displayedColumnsOnly) { $gridName = null !== $this->request->get('gridName') ? $this->request->get('gridName') : 'product-grid'; if (isset($this->request->get($gridName)['_parameters'])) { $columns = explode(',', $this->request->get($gridName)['_parameters']['view']['columns']); } else { $columns = array_keys($this->datagridManager->getConfigurationForGrid($gridName)['columns']); } $dynamicConfiguration = array_merge($dynamicConfiguration, ['selected_properties' => $columns]); } $configuration = array_merge($rawParameters, $dynamicConfiguration); $this->jobLauncher->launch($jobInstance, $this->getUser(), $configuration); return new Response(); }
/** * Return the filter configured in the grid ($datagridName) * * @return array */ protected function getSystemFilters() { $systemFilters = $this->datagridManager->getConfigurationForGrid($this->datagridName)->offsetGetByPath('[filters][columns]'); $formattedSystemFilters = []; foreach ($systemFilters as $code => $systemFilter) { if (!in_array($code, $this->excludedFilters)) { $formattedSystemFilters['System'][$code] = $systemFilter['label']; } } return $formattedSystemFilters; }
/** * @dataProvider datagridConfigurationProvider */ public function testGetDatagridConfiguration($names, $expectedResolverCall, $expectedException) { if ($expectedException) { $this->setExpectedException('\\RuntimeException'); } $this->resolver->expects($this->exactly($expectedResolverCall))->method('resolve')->will($this->returnArgument(1)); foreach ($names as $name) { $result = $this->manager->getConfigurationForGrid($name); $this->assertInstanceOf('Oro\\Bundle\\DataGridBundle\\Datagrid\\Common\\DatagridConfiguration', $result); $this->assertEquals($name, $result->getName()); } }