for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace rootLogin\JSRoutingProvider\Provider;
use rootLogin\JSRoutingProvider\JSRoutingProvider;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Response;
class SilexJSRoutingControllerProvider implements ControllerProviderInterface
{
/**
* @var Application
*/
private $app;
* @var JSRoutingProvider
private $jsrp;
public function connect(Application $app)
$this->app = $app;
$this->jsrp = new JSRoutingProvider($app);
/** @var \Silex\ControllerCollection $controllers */
$controllers = $app['controllers_factory'];
$controllers->get("/router.js", function() {
return new Response(
$this->jsrp->getJavaScript(),
200,
array("Content-Type" => "text/javascript")
);
})->bind("jsrouter")->getRoute()->setOption("expose",true);
$controllers->get("/routing.js", function() {
$this->jsrp->getJSwithRoutes(),
})->bind("jsrouting")->getRoute()->setOption("expose",true);
$controllers->get("/routes.js", function() {
$this->jsrp->getJSRoutes(),
})->bind("jsroutes")->getRoute()->setOption("expose",true);
return $controllers;
}