Applications cleanup

This commit is contained in:
Romain Neutron
2012-09-28 10:07:04 +02:00
parent 76e6d4015f
commit d5325dba2b
8 changed files with 1301 additions and 1555 deletions

View File

@@ -1,58 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2012 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Controller\Admin\Collection;
use Alchemy\Phrasea\Controller\Admin\ConnectedUsers;
use Alchemy\Phrasea\Controller\Admin\Dashboard;
use Alchemy\Phrasea\Controller\Admin\Databox;
use Alchemy\Phrasea\Controller\Admin\Databoxes;
use Alchemy\Phrasea\Controller\Admin\Description;
use Alchemy\Phrasea\Controller\Admin\Fields;
use Alchemy\Phrasea\Controller\Admin\Publications;
use Alchemy\Phrasea\Controller\Admin\Root;
use Alchemy\Phrasea\Controller\Admin\Setup;
use Alchemy\Phrasea\Controller\Admin\Sphinx;
use Alchemy\Phrasea\Controller\Admin\Subdefs;
use Alchemy\Phrasea\Controller\Admin\Users;
use Alchemy\Phrasea\Controller\Admin\TaskManager;
use Alchemy\Phrasea\Controller\Utils\ConnectionTest;
use Alchemy\Phrasea\Controller\Utils\PathFileTest;
use Silex\ControllerProviderInterface;
use Silex\Application As SilexApplication;
class Admin implements ControllerProviderInterface
{
public function connect(SilexApplication $app)
{
$controllers = $app['controllers_factory'];
$controllers->mount('/', new Root());
$controllers->mount('/dashboard', new Dashboard());
$controllers->mount('/collection', new Collection());
$controllers->mount('/databox', new Databox());
$controllers->mount('/databoxes', new Databoxes());
$controllers->mount('/setup', new Setup());
$controllers->mount('/sphinx', new Sphinx());
$controllers->mount('/connected-users', new ConnectedUsers());
$controllers->mount('/publications', new Publications());
$controllers->mount('/users', new Users());
$controllers->mount('/fields', new Fields());
$controllers->mount('/subdefs', new Subdefs());
$controllers->mount('/description', new Description());
$controllers->mount('/tests/connection', new ConnectionTest());
$controllers->mount('/tests/pathurl', new PathFileTest());
return $controllers;
}
}

View File

@@ -11,24 +11,21 @@
namespace Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Application as PhraseaApplication;
use Alchemy\Phrasea\BaseApplication;
use Silex\Application as SilexApplication;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
return call_user_func(function($environment = 'prod') {
$app = new PhraseaApplication($environment);
$app = new BaseApplication($environment);
/**
* disable session
*/
$app['session.test'] = true;
/**
* @var API_OAuth2_Token
@@ -54,7 +51,6 @@ return call_user_func(function($environment = 'prod') {
* @ throws \API_V1_exception_forbidden
*/
$app->before(function($request) use ($app) {
$registry = $app['phraseanet.registry'];
$oauth2_adapter = new \API_OAuth2_Adapter($app);
$oauth2_adapter->verifyAccessToken();
@@ -64,7 +60,7 @@ return call_user_func(function($environment = 'prod') {
/* @var $oAuth2App \API_OAuth2_Application */
if ($oAuth2App->get_client_id() == \API_OAuth2_Application_Navigator::CLIENT_ID
&& !$registry->get('GV_client_navigator')) {
&& !$app['phraseanet.registry']->get('GV_client_navigator')) {
throw new \API_V1_exception_forbidden(_('The use of phraseanet Navigator is not allowed'));
}
@@ -76,10 +72,6 @@ return call_user_func(function($environment = 'prod') {
$auth = new \Session_Authentication_None($user);
$app->openAccount($auth, $oauth2_adapter->get_ses_id());
/**
* TODO Neutron => remove
*/
$oauth2_adapter->remember_this_ses_id($app['session']->get('phrasea_session_id'));
return;
@@ -187,12 +179,9 @@ return call_user_func(function($environment = 'prod') {
* Parameters :
*
*/
$route = '/monitor/scheduler/';
$app->get(
$route, function(SilexApplication $app, Request $request) {
$app->get('/monitor/scheduler/', function(SilexApplication $app, Request $request) {
return $app['api']->get_scheduler($app)->get_response();
}
)->before($mustBeAdmin);
})->before($mustBeAdmin);
/**
* Get all tasks information
@@ -206,8 +195,7 @@ return call_user_func(function($environment = 'prod') {
*/
$app->get('/monitor/tasks/', function(SilexApplication $app, Request $request) {
return $app['api']->get_task_list($app)->get_response();
}
)->before($mustBeAdmin);
})->before($mustBeAdmin);
/**
* Get task informations
@@ -221,8 +209,7 @@ return call_user_func(function($environment = 'prod') {
*/
$app->get('/monitor/task/{task_id}/', function(SilexApplication $app, Request $request, $task_id) {
return $app['api']->get_task($app, $task_id)->get_response();
}
)->before($mustBeAdmin)->assert('task_id', '\d+');
})->before($mustBeAdmin)->assert('task_id', '\d+');
/**
* Start task
@@ -237,8 +224,7 @@ return call_user_func(function($environment = 'prod') {
*/
$app->post('/monitor/task/{task_id}/', function(SilexApplication $app, Request $request, $task_id) {
return $app['api']->set_task_property($app, $task_id)->get_response();
}
)->before($mustBeAdmin)->assert('task_id', '\d+');
})->before($mustBeAdmin)->assert('task_id', '\d+');
/**
* Start task
@@ -252,8 +238,7 @@ return call_user_func(function($environment = 'prod') {
*/
$app->post('/monitor/task/{task_id}/start/', function(SilexApplication $app, Request $request, $task_id) {
return $app['api']->start_task($app, $task_id)->get_response();
}
)->before($mustBeAdmin);
})->before($mustBeAdmin);
/**
* Stop task
@@ -267,8 +252,7 @@ return call_user_func(function($environment = 'prod') {
*/
$app->post('/monitor/task/{task_id}/stop/', function(SilexApplication $app, Request $request, $task_id) {
return $app['api']->stop_task($app, $task_id)->get_response();
}
)->before($mustBeAdmin);
})->before($mustBeAdmin);
/**
* Get some information about phraseanet
@@ -282,8 +266,7 @@ return call_user_func(function($environment = 'prod') {
*/
$app->get('/monitor/phraseanet/', function(SilexApplication $app, Request $request) {
return $app['api']->get_phraseanet_monitor($app)->get_response();
}
)->before($mustBeAdmin);
})->before($mustBeAdmin);
/**
* Route : /databoxes/list/
@@ -295,8 +278,7 @@ return call_user_func(function($environment = 'prod') {
*/
$app->get('/databoxes/list/', function(SilexApplication $app, Request $request) {
return $app['api']->get_databoxes($request)->get_response();
}
);
});
/**
* Route /databoxes/DATABOX_ID/collections/
@@ -310,8 +292,7 @@ return call_user_func(function($environment = 'prod') {
return $app['api']
->get_databox_collections($app['request'], $databox_id)
->get_response();
}
)->assert('databox_id', '\d+');
})->assert('databox_id', '\d+');
$app->get('/databoxes/{any_id}/collections/', $bad_request_exception);
@@ -328,8 +309,7 @@ return call_user_func(function($environment = 'prod') {
return $app['api']
->get_databox_status($app['request'], $databox_id)
->get_response();
}
)->assert('databox_id', '\d+');
})->assert('databox_id', '\d+');
$app->get('/databoxes/{any_id}/status/', $bad_request_exception);
@@ -345,8 +325,7 @@ return call_user_func(function($environment = 'prod') {
return $app['api']
->get_databox_metadatas($app['request'], $databox_id)
->get_response();
}
)->assert('databox_id', '\d+');
})->assert('databox_id', '\d+');
$app->get('/databoxes/{any_id}/metadatas/', $bad_request_exception);
@@ -362,20 +341,17 @@ return call_user_func(function($environment = 'prod') {
return $app['api']
->get_databox_terms($app['request'], $databox_id)
->get_response();
}
)->assert('databox_id', '\d+');
})->assert('databox_id', '\d+');
$app->get('/databoxes/{any_id}/termsOfUse/', $bad_request_exception);
$app->get('/quarantine/list/', function(SilexApplication $app, Request $request) {
return $app['api']->list_quarantine($app, $request)->get_response();
}
);
});
$app->get('/quarantine/item/{lazaret_id}/', function($lazaret_id, SilexApplication $app, Request $request) {
return $app['api']->list_quarantine_item($lazaret_id, $app, $request)->get_response();
}
);
});
/**
* Route : /records/add/
@@ -387,8 +363,7 @@ return call_user_func(function($environment = 'prod') {
*/
$app->post('/records/add/', function(SilexApplication $app, Request $request) {
return $app['api']->add_record($app, $request)->get_response();
}
);
});
/**
* Route : /records/search/
@@ -408,15 +383,13 @@ return call_user_func(function($environment = 'prod') {
*/
$app->match('/records/search/', function(SilexApplication $app) {
return $app['api']->search_records($app['request'])->get_response();
}
);
});
$app->get('/records/{databox_id}/{record_id}/caption/', function(SilexApplication $app, $databox_id, $record_id) {
return $app['api']
->caption_records($app['request'], $databox_id, $record_id)
->get_response();
}
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
})->assert('databox_id', '\d+')->assert('record_id', '\d+');
$app->get('/records/{any_id}/{anyother_id}/caption/', $bad_request_exception);
@@ -434,8 +407,7 @@ return call_user_func(function($environment = 'prod') {
return $app['api']
->get_record_metadatas($app['request'], $databox_id, $record_id)
->get_response();
}
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
})->assert('databox_id', '\d+')->assert('record_id', '\d+');
$app->get('/records/{any_id}/{anyother_id}/metadatas/', $bad_request_exception);
@@ -453,8 +425,7 @@ return call_user_func(function($environment = 'prod') {
return $app['api']
->get_record_status($app['request'], $databox_id, $record_id)
->get_response();
}
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
})->assert('databox_id', '\d+')->assert('record_id', '\d+');
$app->get('/records/{any_id}/{anyother_id}/status/', $bad_request_exception);
@@ -472,8 +443,7 @@ return call_user_func(function($environment = 'prod') {
return $app['api']
->get_record_related($app['request'], $databox_id, $record_id)
->get_response();
}
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
})->assert('databox_id', '\d+')->assert('record_id', '\d+');
$app->get('/records/{any_id}/{anyother_id}/related/', $bad_request_exception);
@@ -491,8 +461,7 @@ return call_user_func(function($environment = 'prod') {
return $app['api']
->get_record_embed($app['request'], $databox_id, $record_id)
->get_response();
}
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
})->assert('databox_id', '\d+')->assert('record_id', '\d+');
$app->get('/records/{any_id}/{anyother_id}/embed/', $bad_request_exception);
@@ -510,8 +479,7 @@ return call_user_func(function($environment = 'prod') {
return $app['api']
->set_record_metadatas($app['request'], $databox_id, $record_id)
->get_response();
}
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
})->assert('databox_id', '\d+')->assert('record_id', '\d+');
$app->post('/records/{any_id}/{anyother_id}/setmetadatas/', $bad_request_exception);
@@ -529,8 +497,7 @@ return call_user_func(function($environment = 'prod') {
return $app['api']
->set_record_status($app['request'], $databox_id, $record_id)
->get_response();
}
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
})->assert('databox_id', '\d+')->assert('record_id', '\d+');
$app->post('/records/{any_id}/{anyother_id}/setstatus/', $bad_request_exception);
@@ -548,8 +515,7 @@ return call_user_func(function($environment = 'prod') {
return $app['api']
->set_record_collection($app['request'], $databox_id, $record_id)
->get_response();
}
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
})->assert('databox_id', '\d+')->assert('record_id', '\d+');
$app->post('/records/{wrong_databox_id}/{wrong_record_id}/setcollection/', $bad_request_exception);
@@ -571,8 +537,7 @@ return call_user_func(function($environment = 'prod') {
*/
$app->get('/baskets/list/', function(SilexApplication $app) {
return $app['api']->search_baskets($app['request'])->get_response();
}
);
});
/**
* Route : /baskets/add/
@@ -584,8 +549,7 @@ return call_user_func(function($environment = 'prod') {
*/
$app->post('/baskets/add/', function(SilexApplication $app) {
return $app['api']->create_basket($app['request'])->get_response();
}
);
});
/**
* Route : /baskets/BASKET_ID/content/
@@ -598,8 +562,7 @@ return call_user_func(function($environment = 'prod') {
*/
$app->get('/baskets/{basket_id}/content/', function(SilexApplication $app, $basket_id) {
return $app['api']->get_basket($app['request'], $basket_id)->get_response();
}
)->assert('basket_id', '\d+');
})->assert('basket_id', '\d+');
$app->get('/baskets/{wrong_basket_id}/content/', $bad_request_exception);
@@ -616,8 +579,7 @@ return call_user_func(function($environment = 'prod') {
return $app['api']
->set_basket_title($app['request'], $basket_id)
->get_response();
}
)->assert('basket_id', '\d+');
})->assert('basket_id', '\d+');
$app->post('/baskets/{wrong_basket_id}/setname/', $bad_request_exception);
@@ -634,8 +596,7 @@ return call_user_func(function($environment = 'prod') {
return $app['api']
->set_basket_description($app['request'], $basket_id)
->get_response();
}
)->assert('basket_id', '\d+');
})->assert('basket_id', '\d+');
$app->post('/baskets/{wrong_basket_id}/setdescription/', $bad_request_exception);
@@ -650,8 +611,7 @@ return call_user_func(function($environment = 'prod') {
*/
$app->post('/baskets/{basket_id}/delete/', function(SilexApplication $app, $basket_id) {
return $app['api']->delete_basket($app['request'], $basket_id)->get_response();
}
)->assert('basket_id', '\d+');
})->assert('basket_id', '\d+');
$app->post('/baskets/{wrong_basket_id}/delete/', $bad_request_exception);
@@ -667,22 +627,19 @@ return call_user_func(function($environment = 'prod') {
return $app['api']
->search_publications($app['request'], $app['phraseanet.user'])
->get_response();
}
);
});
$app->get('/feeds/content/', function(SilexApplication $app) {
return $app['api']
->get_publications($app['request'], $app['phraseanet.user'])
->get_response();
}
);
});
$app->get('/feeds/entry/{entry_id}/', function(SilexApplication $app, $entry_id) {
return $app['api']
->get_feed_entry($app['request'], $entry_id, $app['phraseanet.user'])
->get_response();
}
)->assert('entry_id', '\d+');
})->assert('entry_id', '\d+');
$app->get('/feeds/entry/{entry_id}/', $bad_request_exception);
@@ -699,8 +656,7 @@ return call_user_func(function($environment = 'prod') {
return $app['api']
->get_publication($app['request'], $feed_id, $app['phraseanet.user'])
->get_response();
}
)->assert('feed_id', '\d+');
})->assert('feed_id', '\d+');
$app->get('/feeds/{wrong_feed_id}/content/', $bad_request_exception);
@@ -745,7 +701,5 @@ return call_user_func(function($environment = 'prod') {
return $response;
});
return $app;
}, $environment ? : null
);
}, isset($environment) ? $environment : null);

View File

@@ -15,28 +15,20 @@ use Silex\Application as SilexApplication;
use Alchemy\Phrasea\Application as PhraseaApplication;
use Symfony\Component\HttpFoundation\Request;
/**
*
* @package APIv1
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
return call_user_func(function() {
$app = new PhraseaApplication();
return call_user_func(function($environment = 'prod') {
$app = new PhraseaApplication($environment);
$app->get('/', function(Request $request, SilexApplication $app) {
$registry = $app['phraseanet.registry'];
$apiAdapter = new \API_V1_adapter($app);
$result = new \API_V1_result($request, $apiAdapter);
return $result->set_datas(
array(
'name' => $registry->get('GV_homeTitle'),
return $result->set_datas(array(
'name' => $app['phraseanet.registry']->get('GV_homeTitle'),
'type' => 'phraseanet',
'description' => $registry->get('GV_metaDescription'),
'description' => $app['phraseanet.registry']->get('GV_metaDescription'),
'documentation' => 'https://docs.phraseanet.com/Devel',
'versions' => array(
'1' => array(
@@ -50,10 +42,8 @@ return call_user_func(function() {
)
)
)
)
)->get_response();
))->get_response();
});
return $app;
}
);
}, isset($environment) ? $environment : null);

View File

@@ -18,24 +18,20 @@ use Symfony\Component\HttpFoundation\Response;
class Lightbox implements ControllerProviderInterface
{
public function connect(SilexApplication $app)
{
$controllers = $app['controllers_factory'];
$controllers->get('/', function (SilexApplication $app) {
\User_Adapter::updateClientInfos($app, 6);
$repository = $app['EM']->getRepository('\Entities\Basket');
$current_user = $app['phraseanet.user'];
/* @var $repository \Repositories\BasketRepository */
$basket_collection = array_merge(
$repository->findActiveByUser($app['phraseanet.user'])
, $repository->findActiveValidationByUser($current_user)
, $repository->findActiveValidationByUser($app['phraseanet.user'])
);
$template = 'lightbox/index.html.twig';
@@ -49,8 +45,7 @@ class Lightbox implements ControllerProviderInterface
'module' => 'lightbox'
)
));
}
);
});
$controllers->get('/ajax/NOTE_FORM/{sselcont_id}/', function(SilexApplication $app, $sselcont_id) {
@@ -68,8 +63,7 @@ class Lightbox implements ControllerProviderInterface
);
return $app['twig']->render('lightbox/note_form.html.twig', $parameters);
}
)->assert('sselcont_id', '\d+');
})->assert('sselcont_id', '\d+');
$controllers->get('/ajax/LOAD_BASKET_ELEMENT/{sselcont_id}/', function(SilexApplication $app, $sselcont_id) {
/* @var $repository \Repositories\BasketElementRepository */
@@ -113,8 +107,7 @@ class Lightbox implements ControllerProviderInterface
return $app->json($ret);
}
}
)->assert('sselcont_id', '\d+');
})->assert('sselcont_id', '\d+');
$controllers->get('/ajax/LOAD_FEED_ITEM/{entry_id}/{item_id}/', function(SilexApplication $app, $entry_id, $item_id) {
@@ -150,8 +143,7 @@ class Lightbox implements ControllerProviderInterface
return $app->json($ret);
}
}
)->assert('entry_id', '\d+')->assert('item_id', '\d+');
})->assert('entry_id', '\d+')->assert('item_id', '\d+');
$controllers->get('/validate/{ssel_id}/', function (SilexApplication $app, $ssel_id) {
@@ -199,8 +191,7 @@ class Lightbox implements ControllerProviderInterface
$response->setCharset('UTF-8');
return $response;
}
)->assert('ssel_id', '\d+');
})->assert('ssel_id', '\d+');
$controllers->get('/compare/{ssel_id}/', function (SilexApplication $app, $ssel_id) {
@@ -248,8 +239,7 @@ class Lightbox implements ControllerProviderInterface
$response->setCharset('UTF-8');
return $response;
}
)->assert('ssel_id', '\d+');
})->assert('ssel_id', '\d+');
$controllers->get('/feeds/entry/{entry_id}/', function (SilexApplication $app, $entry_id) {
@@ -277,8 +267,7 @@ class Lightbox implements ControllerProviderInterface
$response->setCharset('UTF-8');
return $response;
}
)->assert('entry_id', '\d+');
})->assert('entry_id', '\d+');
$controllers->get('/ajax/LOAD_REPORT/{ssel_id}/', function(SilexApplication $app, $ssel_id) {
@@ -297,8 +286,7 @@ class Lightbox implements ControllerProviderInterface
$response->setCharset('UTF-8');
return $response;
}
)->assert('ssel_id', '\d+');
})->assert('ssel_id', '\d+');
$controllers->post('/ajax/SET_NOTE/{sselcont_id}/', function (SilexApplication $app, $sselcont_id) {
$output = array('error' => true, 'datas' => _('Erreur lors de l\'enregistrement des donnees'));
@@ -336,8 +324,7 @@ class Lightbox implements ControllerProviderInterface
}
return $app->json($output);
}
)->assert('sselcont_id', '\d+');
})->assert('sselcont_id', '\d+');
$controllers->post('/ajax/SET_ELEMENT_AGREEMENT/{sselcont_id}/', function(SilexApplication $app, $sselcont_id) {
$request = $app['request'];
@@ -399,8 +386,7 @@ class Lightbox implements ControllerProviderInterface
}
return $app->json($ret);
}
)->assert('sselcont_id', '\d+');
})->assert('sselcont_id', '\d+');
$controllers->post('/ajax/SET_RELEASE/{ssel_id}/', function(SilexApplication $app, $ssel_id) {
@@ -461,8 +447,7 @@ class Lightbox implements ControllerProviderInterface
}
return $app->json($datas);
}
)->assert('ssel_id', '\d+');
})->assert('ssel_id', '\d+');
return $controllers;
}

View File

@@ -18,7 +18,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\Request;
/**
*
*
* @package OAuth2 Connector
*
@@ -170,5 +169,4 @@ return call_user_func(function($environment = 'prod') {
});
return $app;
}, $environment ? : null
);
}, isset($environment) ? $environment : null);

View File

@@ -1,96 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2012 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Application as PhraseaApplication;
use Alchemy\Phrasea\Controller\Prod\Basket;
use Alchemy\Phrasea\Controller\Prod\Bridge;
use Alchemy\Phrasea\Controller\Prod\Edit;
use Alchemy\Phrasea\Controller\Prod\Feed;
use Alchemy\Phrasea\Controller\Prod\Language;
use Alchemy\Phrasea\Controller\Prod\Lazaret;
use Alchemy\Phrasea\Controller\Prod\MoveCollection;
use Alchemy\Phrasea\Controller\Prod\MustacheLoader;
use Alchemy\Phrasea\Controller\Prod\Order;
use Alchemy\Phrasea\Controller\Prod\Printer;
use Alchemy\Phrasea\Controller\Prod\Push;
use Alchemy\Phrasea\Controller\Prod\Query;
use Alchemy\Phrasea\Controller\Prod\Root;
use Alchemy\Phrasea\Controller\Prod\Story;
use Alchemy\Phrasea\Controller\Prod\Tools;
use Alchemy\Phrasea\Controller\Prod\Tooltip;
use Alchemy\Phrasea\Controller\Prod\TOU;
use Alchemy\Phrasea\Controller\Prod\Upload;
use Alchemy\Phrasea\Controller\Prod\UserPreferences;
use Alchemy\Phrasea\Controller\Prod\UsrLists;
use Alchemy\Phrasea\Controller\Prod\WorkZone;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpFoundation\Response;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
return call_user_func(function() {
$app = new PhraseaApplication();
$app->mount('/UserPreferences/', new UserPreferences());
$app->mount('/query/', new Query());
$app->mount('/order/', new Order());
$app->mount('/baskets', new Basket());
$app->mount('/story', new Story());
$app->mount('/WorkZone', new WorkZone());
$app->mount('/lists', new UsrLists());
$app->mount('/MustacheLoader', new MustacheLoader());
$app->mount('/records/edit', new Edit());
$app->mount('/records/movecollection', new MoveCollection());
$app->mount('/bridge/', new Bridge());
$app->mount('/push/', new Push());
$app->mount('/printer/', new Printer());
$app->mount('/TOU/', new TOU());
$app->mount('/feeds', new Feed());
$app->mount('/tooltip', new Tooltip());
$app->mount('/language', new Language());
$app->mount('/tools/', new Tools());
$app->mount('/lazaret/', new Lazaret());
$app->mount('/upload/', new Upload());
$app->mount('/', new Root());
$app->error(function (\Exception $e, $code) use ($app) {
/* @var $request \Symfony\Component\HttpFoundation\Request */
$request = $app['request'];
if ($request->getRequestFormat() == 'json') {
$datas = array(
'success' => false
, 'message' => $e->getMessage()
);
return $app->json($datas, 200, array('X-Status-Code' => 200));
}
if ($e instanceof \Exception_BadRequest) {
return new Response('Bad Request', 400, array('X-Status-Code' => 400));
}
if ($e instanceof \Exception_NotFound) {
return new Response('Not Found', 404, array('X-Status-Code' => 404));
}
if ($e instanceof \Exception_Forbidden) {
return new Response('Not Found', 403, array('X-Status-Code' => 403));
}
});
return $app;
}
);

View File

@@ -55,20 +55,12 @@ use Alchemy\Phrasea\Controller\Prod\UsrLists;
use Alchemy\Phrasea\Controller\Prod\WorkZone;
use Alchemy\Phrasea\Controller\Utils\ConnectionTest;
use Alchemy\Phrasea\Controller\Utils\PathFileTest;
use Silex\ControllerProviderInterface;
use Alchemy\Phrasea\Controller\Login\Authenticate as AuthenticateController;
use Silex\Application as SilexApp;
use Symfony\Component\HttpFoundation\Response;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
return call_user_func(function($environment = null) {
$app = new PhraseaApplication($environment);
// $app->enableEvents();
$app->before(function () use ($app) {
return $app['firewall']->requireSetup($app);
@@ -101,7 +93,6 @@ return call_user_func(function($environment = null) {
$app->mount('/developers/', new Developers());
$app->mount('/lightbox/', new Lightbox());
$app->mount('/datafiles/', new Datafiles());
$app->mount('/permalink/', new Permalink());
@@ -122,7 +113,6 @@ return call_user_func(function($environment = null) {
$app->mount('/admin/tests/connection', new ConnectionTest());
$app->mount('/admin/tests/pathurl', new PathFileTest());
$app->mount('/prod/UserPreferences/', new UserPreferences());
$app->mount('/prod/query/', new Query());
$app->mount('/prod/order/', new Order());
@@ -146,14 +136,9 @@ return call_user_func(function($environment = null) {
$app->mount('/prod/', new Prod());
$app->error(function(\Exception $e) use ($app) {
$request = $app['request'];
if ($e instanceof \Bridge_Exception) {
$params = array(
'message' => $e->getMessage()
, 'file' => $e->getFile()
@@ -188,9 +173,6 @@ return call_user_func(function($environment = null) {
return $response;
}
$request = $app['request'];
if ($request->getRequestFormat() == 'json') {
$datas = array(
'success' => false
@@ -199,6 +181,7 @@ return call_user_func(function($environment = null) {
return $app->json($datas, 200, array('X-Status-Code' => 200));
}
if ($e instanceof \Exception_BadRequest) {
return new Response('Bad Request', 400, array('X-Status-Code' => 400));
}
@@ -206,7 +189,6 @@ return call_user_func(function($environment = null) {
return new Response('Forbidden', 403, array('X-Status-Code' => 403));
}
if ($e instanceof \Exception_Session_NotAuthenticated) {
$code = 403;
$message = 'Forbidden';
@@ -224,5 +206,4 @@ return call_user_func(function($environment = null) {
});
return $app;
}, isset($environment) ? $environment : null
);
}, isset($environment) ? $environment : null);

View File

@@ -13,18 +13,12 @@ namespace Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Configuration;
use Alchemy\Phrasea\Application as PhraseaApplication;
use Symfony\Component\HttpFoundation\Response;
use Alchemy\Phrasea\Controller\Setup\Installer;
use Alchemy\Phrasea\Controller\Setup\Upgrader;
use Alchemy\Phrasea\Controller\Utils\ConnectionTest;
use Alchemy\Phrasea\Controller\Utils\PathFileTest;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
return call_user_func(function() {
return call_user_func(function($environment = null) {
$app = new PhraseaApplication();
@@ -33,7 +27,7 @@ return call_user_func(function() {
$app->before(function($a) use ($app) {
if (\setup::is_installed()) {
if ( ! $app['phraseanet.appbox']->need_major_upgrade()) {
if (!$app['phraseanet.appbox']->need_major_upgrade()) {
throw new \Exception_Setup_PhraseaAlreadyInstalled();
}
@@ -47,7 +41,6 @@ return call_user_func(function() {
$connexionInc = new \SplFileInfo(__DIR__ . '/../../../../config/connexion.inc');
$configInc = new \SplFileInfo(__DIR__ . '/../../../../config/config.inc');
echo " config at ".__FILE__."\n";
$configuration = Configuration::build();
$configuration->upgradeFromOldConf($configInc, $connexionInc);
@@ -77,10 +70,9 @@ return call_user_func(function() {
return $app->redirect('/login/');
}
throw $e;
// return new Response('Internal Server Error', 500);
return new Response('Internal Server Error', 500, array('X-Status-Code' => 500));
});
return $app;
}
}, isset($environment) ? $environment : null
);