comparison src/DML/MainVisBundle/Controller/DefaultController.php @ 0:493bcb69166c

added public content
author Daniel Wolff
date Tue, 09 Feb 2016 20:54:02 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:493bcb69166c
1 <?php
2
3 namespace DML\MainVisBundle\Controller;
4
5 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
7 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
8
9 class DefaultController extends Controller
10 {
11 /**
12 * @Route("/", name="default_index")
13 * @Template()
14 *
15 * expected GET params
16 * api2 [client+server] switches to an alternative api
17 * jasmine [client+server] enables jasmine
18 * no_data_caching [client] appends "random" to all API requests
19 * show_assets_version [client] shows a coloured box with assets version (helps see changes in css / js) ='
20 * show_raw_data [client] populates vis instances with raw data
21 */
22 public function indexAction()
23 {
24 $alternativeApiRootPaths = array('//mirg.city.ac.uk/co/api/'); // array('//lewes.nsqdc.city.ac.uk:4060/cp/api/')
25 $defaultApiRootPaths = array('//mirg.city.ac.uk/cp/api/');
26 $swapAPIs = strpos($this->get('request')->getHttpHost(), 'mirg') !== false;
27
28 if ($swapAPIs) {
29 $bubble = $defaultApiRootPaths;
30 $defaultApiRootPaths = $alternativeApiRootPaths;
31 $alternativeApiRootPaths = $bubble;
32 }
33
34 return array (
35 'enableJasmine' => $this->get('request')->query->has('jasmine'), // JS behaviour tests powered by jasmine.js
36 //'enableJasmine' => true,
37 'musicLibrary' => array(
38 'dataVersion' => 2,
39 'dataCaching' => !$this->get('request')->query->has('no_data_caching'),
40 //'apiRootPaths' => array('http://mirg.city.ac.uk/dmlapi/api/'),
41 //'apiRootPaths' => array('//lewes.nsqdc.city.ac.uk:3020/cp/api/'),
42 'apiRootPaths' => $this->get('request')->query->has('api2')
43 ? $alternativeApiRootPaths
44 : $defaultApiRootPaths,
45 'defaultApiRootPaths' => $defaultApiRootPaths,
46 'apiVersion' => 4
47 ),
48 'project' => $this->container->getParameter('anonymous')
49 ? array(
50 'shortTitle' => ' ◦◦◦',
51 'title' => 'Anonymous Project',
52 'anonymous' => false
53 )
54 : array(
55 'shortTitle' => 'DML',
56 'title' => 'Digital Music Lab',
57 'anonymous' => false
58 )
59 );
60 }
61
62 /**
63 * @Route("/web/")
64 * @Template()
65 */
66 public function redirectFromWebAction()
67 {
68 return $this->redirect($this->generateUrl("default_index"), 301);
69 }
70
71 }