diff --git a/simpli-sf3-test-interview/.gitignore b/simpli-sf3-test-interview/.gitignore index 2f75ca1..d334a6b 100644 --- a/simpli-sf3-test-interview/.gitignore +++ b/simpli-sf3-test-interview/.gitignore @@ -15,3 +15,4 @@ !var/SymfonyRequirements.php /vendor/ /web/bundles/ +.idea \ No newline at end of file diff --git a/simpli-sf3-test-interview/src/AppBundle/Controller/DefaultController.php b/simpli-sf3-test-interview/src/AppBundle/Controller/DefaultController.php index cecd334..ca4a32e 100644 --- a/simpli-sf3-test-interview/src/AppBundle/Controller/DefaultController.php +++ b/simpli-sf3-test-interview/src/AppBundle/Controller/DefaultController.php @@ -5,17 +5,19 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; +use AppBundle\Service\InputDataService; class DefaultController extends Controller { /** * @Route("/", name="homepage") */ - public function indexAction(Request $request) + public function indexAction(InputDataService $inputData) { - // replace this example code with whatever you need - return $this->render('default/index.html.twig', [ - 'base_dir' => realpath($this->getParameter('kernel.project_dir')).DIRECTORY_SEPARATOR, - ]); + $result = $inputData->process($this->getParameter('inputData')); + + return $this->render('AppBundle:Default:index.html.twig', array( + 'result' => $result + )); } } diff --git a/simpli-sf3-test-interview/src/AppBundle/Resources/views/Default/index.html.twig b/simpli-sf3-test-interview/src/AppBundle/Resources/views/Default/index.html.twig new file mode 100644 index 0000000..e49aa4e --- /dev/null +++ b/simpli-sf3-test-interview/src/AppBundle/Resources/views/Default/index.html.twig @@ -0,0 +1,34 @@ + + + + + +

Our super table

+ + + + + + + + {% for data in result %} + + + + + + + {% endfor %} +
Item1Item2Item1 + item2Paire/impaire
{{ data[0] }}{{ data[1] }}{{ data[2] }}{{ data[3] }}
+ + \ No newline at end of file diff --git a/simpli-sf3-test-interview/src/AppBundle/Service/InputDataService.php b/simpli-sf3-test-interview/src/AppBundle/Service/InputDataService.php new file mode 100644 index 0000000..b2b0258 --- /dev/null +++ b/simpli-sf3-test-interview/src/AppBundle/Service/InputDataService.php @@ -0,0 +1,39 @@ + $v) + { + if (!isset($results[$k][0])) + $results[$k][0] = 0; + if (!isset($results[$k][1])) + $results[$k][1] = 0; + $results[$k][2] = 0; + $results[$k][3] = ''; + } + + foreach ($input as $k => $v) + { + if (count($v) == 2) + { + $results[$k][2] = $v[0] + $v[1]; + if (($results[$k][2] % 2) == 0) + $results[$k][3] = "Paire"; + else + $results[$k][3] = "Impaire"; + } + } + return $results; + } +} \ No newline at end of file diff --git a/simpli-sf3-test-interview/web/config.php b/simpli-sf3-test-interview/web/config.php index fd7e17e..5ac1985 100644 --- a/simpli-sf3-test-interview/web/config.php +++ b/simpli-sf3-test-interview/web/config.php @@ -22,7 +22,7 @@ exit('This script is only accessible from localhost.'); } -require_once dirname(__FILE__).'/../var/SymfonyRequirements.php'; +require_once dirname(__FILE__).'/./SymfonyRequirements.php'; $symfonyRequirements = new SymfonyRequirements();