Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions simpli-sf3-test-interview/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
!var/SymfonyRequirements.php
/vendor/
/web/bundles/
.idea
Original file line number Diff line number Diff line change
Expand Up @@ -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
));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<html>
<head>
<style>
table {
width: 100%;
}
table, th, td {
border: 1px solid black;
}
th {
background-color: #5574ff;
}
</style>
</head>
<body>
<h1>Our super table</h1>
<table>
<tr>
<th>Item1</th>
<th>Item2</th>
<th>Item1 + item2</th>
<th>Paire/impaire</th>
</tr>
{% for data in result %}
<tr>
<td>{{ data[0] }}</td>
<td>{{ data[1] }}</td>
<td>{{ data[2] }}</td>
<td>{{ data[3] }}</td>
</tr>
{% endfor %}
</table>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace AppBundle\Service;

class InputDataService
{
public function process($input = null)
{
$results = null;
if (!$input)
return null;

$results = $input;

// init index 2 and 3 for next step
foreach ($input as $k => $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;
}
}
2 changes: 1 addition & 1 deletion simpli-sf3-test-interview/web/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down