Add use of core serializer

This commit is contained in:
Romain Neutron
2012-01-23 18:15:15 +01:00
parent 59fb747ca6
commit 7f0982848a
6 changed files with 345 additions and 288 deletions

View File

@@ -33,27 +33,43 @@ class PathFileTest implements ControllerProviderInterface
$controllers = new ControllerCollection();
$controllers->get('/path/', function() use ($app)
{
$path = $app['request']->get('path');
{
$path = $app['request']->get('path');
return new Response(\p4string::jsonencode(array(
'exists' => file_exists($path)
, 'file' => is_file($path)
, 'dir' => is_dir($path)
, 'readable' => is_readable($path)
, 'writeable' => is_writable($path)
, 'executable' => is_executable($path)
)), 200, array('application/json'));
});
$Serializer = $app['Core']['Serializer'];
return new Response(
$Serializer->serialize(
array(
'exists' => file_exists($path)
, 'file' => is_file($path)
, 'dir' => is_dir($path)
, 'readable' => is_readable($path)
, 'writeable' => is_writable($path)
, 'executable' => is_executable($path)
)
, 'json'
)
, 200
, array('application/json')
);
});
$controllers->get('/url/', function() use ($app)
{
$url = $app['request']->get('url');
{
$url = $app['request']->get('url');
return new Response(\p4string::jsonencode(array(
'code' => \http_query::getHttpCodeFromUrl($url)
)), 200, array('application/json'));
});
return new Response(
$Serializer->serialize(
array(
'code' => \http_query::getHttpCodeFromUrl($url)
)
, 'json'
)
, 200
, array('application/json')
);
});
return $controllers;