Cleanup controllers

This commit is contained in:
Romain Neutron
2012-09-28 12:57:11 +02:00
parent 697b234d54
commit f68cae2bb4
21 changed files with 2114 additions and 2154 deletions

View File

@@ -53,8 +53,7 @@ class Bridge implements ControllerProviderInterface
return;
});
$controllers->post('/manager/'
, function(Application $app) {
$controllers->post('/manager/', function(Application $app) {
$route = new RecordHelper\Bridge($app, $app['request']);
$appbox = $app['phraseanet.appbox'];
$user = $app['phraseanet.user'];
@@ -66,8 +65,7 @@ class Bridge implements ControllerProviderInterface
, 'current_account_id' => ''
);
return new Response($app['twig']->render('prod/actions/Bridge/index.html.twig', $params)
);
return $app['twig']->render('prod/actions/Bridge/index.html.twig', $params);
});
$controllers->get('/login/{api_name}/', function(Application $app, $api_name) {
@@ -110,7 +108,7 @@ class Bridge implements ControllerProviderInterface
$params = array('error_message' => $error_message);
return new Response($app['twig']->render('prod/actions/Bridge/callback.html.twig', $params));
return $app['twig']->render('prod/actions/Bridge/callback.html.twig', $params);
});
$controllers->get('/adapter/{account_id}/logout/', function(Application $app, $account_id) {
@@ -140,12 +138,10 @@ class Bridge implements ControllerProviderInterface
, 'notice_message' => $app['request']->query->get('notice')
);
return new Response($app['twig']->render('prod/actions/Bridge/records_list.html.twig', $params));
})
->assert('account_id', '\d+');
return $app['twig']->render('prod/actions/Bridge/records_list.html.twig', $params);
})->assert('account_id', '\d+');
$controllers->get('/adapter/{account_id}/load-elements/{type}/'
, function($account_id, $type) use ($app) {
$controllers->get('/adapter/{account_id}/load-elements/{type}/', function($account_id, $type) use ($app) {
$page = max((int) $app['request']->query->get('page'), 0);
$quantity = 5;
$offset_start = max(($page - 1) * $quantity, 0);
@@ -165,12 +161,10 @@ class Bridge implements ControllerProviderInterface
, 'notice_message' => $app['request']->query->get('notice')
);
return new Response($app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params));
})
->assert('account_id', '\d+');
return $app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params);
})->assert('account_id', '\d+');
$controllers->get('/adapter/{account_id}/load-containers/{type}/'
, function(Application $app, $account_id, $type) {
$controllers->get('/adapter/{account_id}/load-containers/{type}/', function(Application $app, $account_id, $type) {
$page = max((int) $app['request']->query->get('page'), 0);
$quantity = 5;
@@ -190,12 +184,10 @@ class Bridge implements ControllerProviderInterface
, 'notice_message' => $app['request']->query->get('notice')
);
return new Response($app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params));
})
->assert('account_id', '\d+');
return $app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params);
})->assert('account_id', '\d+');
$controllers->get('/action/{account_id}/{action}/{element_type}/'
, function(Application $app, $account_id, $action, $element_type) {
$controllers->get('/action/{account_id}/{action}/{element_type}/', function(Application $app, $account_id, $action, $element_type) {
$appbox = $app['phraseanet.appbox'];
$account = \Bridge_Account::load_account($app, $account_id);
@@ -257,11 +249,10 @@ class Bridge implements ControllerProviderInterface
$template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.html.twig';
return new Response($app['twig']->render($template, $params));
return $app['twig']->render($template, $params);
})->assert('account_id', '\d+');
$controllers->post('/action/{account_id}/{action}/{element_type}/'
, function(Application $app, $account_id, $action, $element_type) {
$controllers->post('/action/{account_id}/{action}/{element_type}/', function(Application $app, $account_id, $action, $element_type) {
$appbox = $app['phraseanet.appbox'];
$account = \Bridge_Account::load_account($app, $account_id);
@@ -302,7 +293,7 @@ class Bridge implements ControllerProviderInterface
$template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.html.twig';
return new Response($app['twig']->render($template, $params));
return $app['twig']->render($template, $params);
}
foreach ($elements as $element_id) {
@@ -382,9 +373,9 @@ class Bridge implements ControllerProviderInterface
, 'adapter_action' => 'upload'
);
return new Response($app['twig']->render(
return $app['twig']->render(
'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params
));
);
});
$controllers->post('/upload/', function(Application $app) {
@@ -417,7 +408,7 @@ class Bridge implements ControllerProviderInterface
, 'adapter_action' => 'upload'
);
return new Response($app['twig']->render('prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params));
return $app['twig']->render('prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params);
}
foreach ($route->get_elements() as $record) {

View File

@@ -233,8 +233,7 @@ class Edit implements ControllerProviderInterface
);
return $app['twig']->render('prod/actions/edit_default.html.twig', $params);
}
);
});
$controllers->get('/vocabulary/{vocabulary}/', function(Application $app, Request $request, $vocabulary) {
$datas = array('success' => false, 'message' => '', 'results' => array());
@@ -273,8 +272,7 @@ class Edit implements ControllerProviderInterface
$datas['results'] = $list;
return $app->json($datas);
}
);
});
$controllers->post('/apply/', function(Application $app, Request $request) {
@@ -412,8 +410,7 @@ class Edit implements ControllerProviderInterface
return $app['twig']->render('prod/actions/edit_default.html.twig', array('edit' => $editing, 'message' => ''));
}
);
});
return $controllers;
}

View File

@@ -37,11 +37,11 @@ class Feed implements ControllerProviderInterface
$feeds = \Feed_Collection::load_all($app, $user);
$publishing = RecordsRequest::fromRequest($app, $request, true, array(), array('bas_chupub'));
return new Response($app['twig']->render('prod/actions/publish/publish.html.twig', array('publishing' => $publishing, 'feeds' => $feeds)));
return $app['twig']->render('prod/actions/publish/publish.html.twig', array('publishing' => $publishing, 'feeds' => $feeds));
});
/**
* I've selected a publication for my ocs, let's publish them
* I've selected a publication for my docs, let's publish them
*/
$controllers->post('/entry/create/', function(Application $app, Request $request) {
try {

View File

@@ -183,11 +183,9 @@ class Lazaret implements ControllerProviderInterface
);
}
$html = $app['twig']->render(
return $app['twig']->render(
'prod/upload/lazaret.html.twig', array('lazaretFiles' => $lazaretFiles)
);
return new Response($html);
}
/**
@@ -514,11 +512,9 @@ class Lazaret implements ControllerProviderInterface
$lazaretThumbFileName = $app['phraseanet.registry']->get('GV_RootPath') . 'tmp/lazaret/' . $lazaretFile->getThumbFilename();
$response = \set_export::stream_file(
return \set_export::stream_file(
$app['phraseanet.registry'], $lazaretThumbFileName, $lazaretFile->getOriginalName(), 'image/jpeg', 'inline'
);
return $response;
}
/**

View File

@@ -63,8 +63,7 @@ class Printer implements ControllerProviderInterface
}
return new Response($PDF->render(), 200, array('Content-Type' => 'application/pdf'));
}
);
});
return $controllers;
}

View File

@@ -116,9 +116,8 @@ class Push implements ControllerProviderInterface
'RecommendedUsers' => $RecommendedUsers
);
return new Response($app['twig']->render('prod/actions/Push.html.twig', $params));
}
);
return $app['twig']->render('prod/actions/Push.html.twig', $params);
});
$controllers->post('/validateform/', function(Application $app) use ($userSelection) {
$push = new RecordHelper\Push($app, $app['request']);
@@ -135,9 +134,8 @@ class Push implements ControllerProviderInterface
'RecommendedUsers' => $RecommendedUsers
);
return new Response($app['twig']->render('prod/actions/Push.html.twig', $params));
}
);
return $app['twig']->render('prod/actions/Push.html.twig', $params);
});
$controllers->post('/send/', function(Application $app) {
$request = $app['request'];
@@ -257,8 +255,7 @@ class Push implements ControllerProviderInterface
}
return $app->json($ret);
}
);
});
$controllers->post('/validate/', function(Application $app) {
$request = $app['request'];
@@ -464,11 +461,9 @@ class Push implements ControllerProviderInterface
}
return $app->json($ret);
}
);
});
$controllers->get('/user/{usr_id}/', function(Application $app, $usr_id) use ($userFormatter) {
$datas = null;
$request = $app['request'];
@@ -582,7 +577,7 @@ class Push implements ControllerProviderInterface
$controllers->get('/add-user/', function(Application $app, Request $request) {
$params = array('callback' => $request->query->get('callback'));
return new Response($app['twig']->render('prod/User/Add.html.twig', $params));
return $app['twig']->render('prod/User/Add.html.twig', $params);
});
$controllers->get('/search-user/', function(Application $app) use ($userFormatter, $listFormatter) {
@@ -621,8 +616,7 @@ class Push implements ControllerProviderInterface
}
return $app->json($datas);
}
);
});
$controllers->match('/edit-list/{list_id}/', function(Application $app, Request $request, $list_id) {
@@ -685,8 +679,7 @@ class Push implements ControllerProviderInterface
$app['twig']->render('prod/actions/Feedback/list.html.twig', $params)
);
}
}
)->assert('list_id', '\d+');
})->assert('list_id', '\d+');
return $controllers;
}

View File

@@ -102,7 +102,7 @@ class Root implements ControllerProviderInterface
}
}
$out = $app['twig']->render('prod/index.html.twig', array(
return $app['twig']->render('prod/index.html.twig', array(
'module_name' => 'Production',
'WorkZone' => new Helper\WorkZone($app, $app['request']),
'module_prod' => new Helper\Prod($app, $app['request']),
@@ -124,8 +124,6 @@ class Root implements ControllerProviderInterface
'thesau_json_bas2sbas' => json_encode($bas2sbas),
'thesau_languages' => \User_Adapter::avLanguages(),
));
return new Response($out);
});
$controllers->post('/multi-export/', function(Application $app, Request $request) {

View File

@@ -30,8 +30,7 @@ class Story implements ControllerProviderInterface
$controllers = $app['controllers_factory'];
$controllers->get('/create/', function(Application $app) {
return new Response($app['twig']->render('prod/Story/Create.html.twig', array()));
return $app['twig']->render('prod/Story/Create.html.twig', array());
});
$controllers->post('/', function(Application $app, Request $request) {
@@ -120,9 +119,7 @@ class Story implements ControllerProviderInterface
return new Response($html);
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
$controllers->post(
'/{sbas_id}/{record_id}/addElements/'
, function(Application $app, Request $request, $sbas_id, $record_id) {
$controllers->post('/{sbas_id}/{record_id}/addElements/', function(Application $app, Request $request, $sbas_id, $record_id) {
$Story = new \record_adapter($app, $sbas_id, $record_id);
$user = $app['phraseanet.user'];
@@ -168,9 +165,7 @@ class Story implements ControllerProviderInterface
}
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
$controllers->post(
'/{sbas_id}/{record_id}/delete/{child_sbas_id}/{child_record_id}/'
, function(Application $app, Request $request, $sbas_id, $record_id, $child_sbas_id, $child_record_id) {
$controllers->post('/{sbas_id}/{record_id}/delete/{child_sbas_id}/{child_record_id}/', function(Application $app, Request $request, $sbas_id, $record_id, $child_sbas_id, $child_record_id) {
$Story = new \record_adapter($app, $sbas_id, $record_id);
$record = new \record_adapter($app, $child_sbas_id, $child_record_id);
@@ -220,9 +215,7 @@ class Story implements ControllerProviderInterface
->assert('sbas_id', '\d+')
->assert('record_id', '\d+');
$controllers->post(
'/{sbas_id}/{record_id}/reorder/'
, function(Application $app, $sbas_id, $record_id) {
$controllers->post('/{sbas_id}/{record_id}/reorder/', function(Application $app, $sbas_id, $record_id) {
$ret = array('success' => false, 'message' => _('An error occured'));
try {
$user = $app['phraseanet.user'];

View File

@@ -167,11 +167,7 @@ class Tools implements ControllerProviderInterface
, 'errorMessage' => $errorMessage
);
return new Response($app['twig']->render($template, $var));
/**
*
*/
return $app['twig']->render($template, $var);
});
$controllers->post('/chgthumb/', function(Application $app, Request $request) {
@@ -214,7 +210,7 @@ class Tools implements ControllerProviderInterface
, 'errorMessage' => $errorMessage
);
return new Response($app['twig']->render($template, $var));
return $app['twig']->render($template, $var);
}
});

View File

@@ -128,8 +128,7 @@ class Tooltip implements ControllerProviderInterface
'view' => $context,
'highlight' => $app['request']->request->get('query'),
'searchEngine' => $search_engine,
)
);
));
}
public function displayTechnicalDatas(Application $app, $sbas_id, $record_id)

View File

@@ -111,8 +111,7 @@ class Upload implements ControllerProviderInterface
'collections' => $this->getGrantedCollections($app['phraseanet.user']),
'maxFileSize' => $maxFileSize,
'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)
)
);
));
}
/**
@@ -132,8 +131,7 @@ class Upload implements ControllerProviderInterface
'collections' => $this->getGrantedCollections($app['phraseanet.user']),
'maxFileSize' => $maxFileSize,
'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)
)
);
));
}
/**