mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Fix JSON responses
This commit is contained in:
@@ -125,7 +125,7 @@ return call_user_func(
|
||||
$ret['note_html'] = $twig->render($template_note, array('basket_element' => $BasketElement));
|
||||
$ret['caption'] = $twig->render($template_caption, array('view' => 'preview', 'record' => $BasketElement->getRecord()));
|
||||
|
||||
return $app->json($app['phraseanet.core']['Serializer']->serialize($ret, 'json'));
|
||||
return $app->json($ret);
|
||||
}
|
||||
}
|
||||
)->assert('sselcont_id', '\d+');
|
||||
@@ -166,7 +166,7 @@ return call_user_func(
|
||||
|
||||
$ret['agreement_html'] = $ret['selector_html'] = $ret['note_html'] = '';
|
||||
|
||||
return $app->json($app['phraseanet.core']['Serializer']->serialize($ret, 'json'));
|
||||
return $app->json($ret);
|
||||
}
|
||||
}
|
||||
)->assert('entry_id', '\d+')->assert('item_id', '\d+');
|
||||
@@ -377,7 +377,7 @@ return call_user_func(
|
||||
$output = array('error' => false, 'datas' => $datas);
|
||||
}
|
||||
|
||||
return $app->json($app['phraseanet.core']['Serializer']->serialize($output, 'json'));
|
||||
return $app->json($output);
|
||||
}
|
||||
)->assert('sselcont_id', '\d+');
|
||||
|
||||
@@ -441,7 +441,7 @@ return call_user_func(
|
||||
$ret['datas'] = $e->getMessage();
|
||||
}
|
||||
|
||||
return $app->json($app['phraseanet.core']['Serializer']->serialize($ret, 'json'));
|
||||
return $app->json($ret);
|
||||
}
|
||||
)->assert('sselcont_id', '\d+');
|
||||
|
||||
@@ -506,10 +506,7 @@ return call_user_func(
|
||||
$datas = array('error' => true, 'datas' => $e->getMessage());
|
||||
}
|
||||
|
||||
$response = new Response($app['phraseanet.core']['Serializer']->serialize($datas, 'json'));
|
||||
$response->setCharset('UTF-8');
|
||||
|
||||
return $response;
|
||||
return $app->json($datas);
|
||||
}
|
||||
)->assert('ssel_id', '\d+');
|
||||
|
||||
|
@@ -74,7 +74,7 @@ return call_user_func(function() {
|
||||
, 'message' => $e->getMessage()
|
||||
);
|
||||
|
||||
return $app->json($app['phraseanet.core']['Serializer']->serialize($datas, 'json'));
|
||||
return $app->json($datas);
|
||||
}
|
||||
if ($e instanceof \Exception_BadRequest) {
|
||||
return new Response('Bad Request', 400);
|
||||
|
@@ -39,7 +39,7 @@ class Fields implements ControllerProviderInterface
|
||||
'is_multi' => $tag->isMulti(),
|
||||
);
|
||||
|
||||
return $app->json($app['phraseanet.core']['Serializer']->serialize($datas, 'json'));
|
||||
return $app->json($datas);
|
||||
});
|
||||
|
||||
$controllers->get('/checkreadonly/', function(PhraseaApplication $app, Request $request) {
|
||||
@@ -52,7 +52,7 @@ class Fields implements ControllerProviderInterface
|
||||
'is_readonly' => ! $tag->isWritable(),
|
||||
);
|
||||
|
||||
return $app->json($app['phraseanet.core']['Serializer']->serialize($datas, 'json'));
|
||||
return $app->json($datas);
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
|
@@ -46,9 +46,7 @@ class Upgrader implements ControllerProviderInterface
|
||||
$controllers->get('/status/', function() use ($app) {
|
||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||
|
||||
$datas = \Setup_Upgrade::get_status();
|
||||
|
||||
return $app->json($app['phraseanet.core']['Serializer']->serialize($datas, 'json'));
|
||||
return $app->json(\Setup_Upgrade::get_status());
|
||||
});
|
||||
|
||||
$controllers->post('/execute/', function() use ($app) {
|
||||
|
@@ -80,7 +80,7 @@ class ConnectionTest implements ControllerProviderInterface
|
||||
, 'is_databox' => $is_databox
|
||||
);
|
||||
|
||||
return $app->json($app['phraseanet.core']['Serializer']->serialize($datas, 'json'));
|
||||
return $app->json($datas);
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
|
@@ -30,30 +30,20 @@ class PathFileTest implements ControllerProviderInterface
|
||||
$controllers->get('/path/', function( Request $request) {
|
||||
$path = $request->get('path');
|
||||
|
||||
return $app->json(
|
||||
$app['phraseanet.core']['Serializer']->serialize(
|
||||
array(
|
||||
return $app->json(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'
|
||||
)
|
||||
);
|
||||
));
|
||||
});
|
||||
|
||||
$controllers->get('/url/', function( Request $request) {
|
||||
$url = $request->get('url');
|
||||
|
||||
return $app->json(
|
||||
$app['phraseanet.core']['Serializer']->serialize(
|
||||
array('code' => \http_query::getHttpCodeFromUrl($url))
|
||||
, 'json'
|
||||
)
|
||||
);
|
||||
return $app->json(array('code' => \http_query::getHttpCodeFromUrl($url)));
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
|
@@ -28,7 +28,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$app['debug'] = true;
|
||||
unset($app['exception_handler']);
|
||||
|
||||
$app['Core']['file-system'] = $this->getMock('Symfony\Component\Filesystem\Filesystem', array('remove'));
|
||||
$app['phraseanet.core']['file-system'] = $this->getMock('Symfony\Component\Filesystem\Filesystem', array('remove'));
|
||||
|
||||
return $app;
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
|
||||
return call_user_func(function() {
|
||||
$app = new \Silex\Application();
|
||||
|
||||
$app['Core'] = \bootstrap::getCore();
|
||||
$app['phraseanet.core'] = \bootstrap::getCore();
|
||||
|
||||
$app['install'] = true;
|
||||
|
||||
|
@@ -2,15 +2,13 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Application;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Alchemy\Phrasea\Controller\Setup as Controller;
|
||||
use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
|
||||
|
||||
return call_user_func(function() {
|
||||
$app = new \Silex\Application();
|
||||
|
||||
$app['Core'] = \bootstrap::getCore();
|
||||
$app['phraseanet.core'] = \bootstrap::getCore();
|
||||
|
||||
$app['upgrade'] = true;
|
||||
|
||||
|
Reference in New Issue
Block a user