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