Added ability to have url parameters
This commit is contained in:
parent
bb278e5d17
commit
5cf6ba2e76
|
@ -1,7 +1,7 @@
|
||||||
default:
|
default:
|
||||||
path: '/'
|
path: '/'
|
||||||
defaults:
|
defaults:
|
||||||
_controller: JeroenED\Webcron\Controller\DefaultController::defaultAction
|
_controller: JeroenED\Webcron\Controller\JobController::defaultAction
|
||||||
|
|
||||||
login:
|
login:
|
||||||
path: '/login'
|
path: '/login'
|
||||||
|
@ -13,3 +13,13 @@ login_check:
|
||||||
methods: ['POST']
|
methods: ['POST']
|
||||||
defaults:
|
defaults:
|
||||||
_controller: JeroenED\Webcron\Controller\SecurityController::loginCheckAction
|
_controller: JeroenED\Webcron\Controller\SecurityController::loginCheckAction
|
||||||
|
|
||||||
|
job_index:
|
||||||
|
path: '/job'
|
||||||
|
defaults:
|
||||||
|
_controller: JeroenED\Webcron\Controller\JobController::defaultAction
|
||||||
|
|
||||||
|
job_view:
|
||||||
|
path: '/job/{id}'
|
||||||
|
defaults:
|
||||||
|
_controller: JeroenED\Webcron\Controller\JobController::viewAction
|
||||||
|
|
|
@ -28,7 +28,9 @@ class Router
|
||||||
$controller = explode('::', $method['_controller']);
|
$controller = explode('::', $method['_controller']);
|
||||||
$controllerObj = new ('\\' . $controller[0])($request, $kernel);
|
$controllerObj = new ('\\' . $controller[0])($request, $kernel);
|
||||||
$action = $controller[1];
|
$action = $controller[1];
|
||||||
$response = $controllerObj->$action();
|
unset($method['_controller']);
|
||||||
|
unset($method['_route']);
|
||||||
|
$response = $controllerObj->$action(...$method);
|
||||||
|
|
||||||
if ($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
|
|
|
@ -30,8 +30,8 @@ class Twig
|
||||||
|
|
||||||
public function addFunctions()
|
public function addFunctions()
|
||||||
{
|
{
|
||||||
$path = new TwigFunction('path', function(string $route) {
|
$path = new TwigFunction('path', function(string $route, array $params) {
|
||||||
return $this->kernel->getRouter()->getUrlForRoute($route);
|
return $this->kernel->getRouter()->getUrlForRoute($route, $params);
|
||||||
});
|
});
|
||||||
$this->environment->addFunction($path);
|
$this->environment->addFunction($path);
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,10 @@ use JeroenED\Webcron\Repository\Job;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class DefaultController extends Controller
|
class JobController extends Controller
|
||||||
{
|
{
|
||||||
public function DefaultAction() {
|
public function DefaultAction()
|
||||||
|
{
|
||||||
if(!isset($_SESSION['isAuthenticated']) || !$_SESSION['isAuthenticated']) {
|
if(!isset($_SESSION['isAuthenticated']) || !$_SESSION['isAuthenticated']) {
|
||||||
return new RedirectResponse($this->generateRoute('login'));
|
return new RedirectResponse($this->generateRoute('login'));
|
||||||
}
|
}
|
||||||
|
@ -18,4 +19,9 @@ class DefaultController extends Controller
|
||||||
$jobs = $jobRepo->getAllJobs();
|
$jobs = $jobRepo->getAllJobs();
|
||||||
return $this->render('job/index.html.twig', ['jobs' => $jobs]);
|
return $this->render('job/index.html.twig', ['jobs' => $jobs]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function viewAction($id)
|
||||||
|
{
|
||||||
|
return new Response('Not implemented yet', Response::HTTP_TOO_EARLY);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
-- job definition
|
||||||
|
CREATE TABLE job (
|
||||||
|
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
name TEXT(25) NOT NULL,
|
||||||
|
"data" TEXT NOT NULL,
|
||||||
|
delay INTEGER,
|
||||||
|
nextrun INTEGER,
|
||||||
|
lastrun INTEGER
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- "user" definition
|
||||||
|
CREATE TABLE "user" (
|
||||||
|
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
email TEXT(50) NOT NULL,
|
||||||
|
password TEXT(72) NOT NULL
|
||||||
|
);
|
|
@ -24,7 +24,7 @@
|
||||||
<td>{{ job.nextrun | date("d/m/Y H:i:s") }}</td>
|
<td>{{ job.nextrun | date("d/m/Y H:i:s") }}</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#" data-id="{{ job.id }}" class="runcron btn btn-default"><span class="glyphicon glyphicon-play"><span></a>
|
<a href="#" data-id="{{ job.id }}" class="runcron btn btn-default"><span class="glyphicon glyphicon-play"><span></a>
|
||||||
<a href="runs.php?jobID={{ job.id }}" class="btn btn-default"><span class="glyphicon glyphicon-align-justify"></span></a>
|
<a href="{{ path('job_view', {'id': job.id}) }}" class="btn btn-default"><span class="glyphicon glyphicon-align-justify"></span></a>
|
||||||
<a href="editjob.php?jobID={{ job.id }}" class="btn btn-default"><span class="glyphicon glyphicon-edit"><span></a>
|
<a href="editjob.php?jobID={{ job.id }}" class="btn btn-default"><span class="glyphicon glyphicon-edit"><span></a>
|
||||||
<a onclick="return confirm('Are you sure you want to delete this job?')" href="overview.php?id={{ job.id }}&action=delete" class="btn btn-default"><span class="glyphicon glyphicon-remove"></span></a>
|
<a onclick="return confirm('Are you sure you want to delete this job?')" href="overview.php?id={{ job.id }}&action=delete" class="btn btn-default"><span class="glyphicon glyphicon-remove"></span></a>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Reference in New Issue