annotate src/DML/MainVisBundle/Controller/DefaultController.php @ 1:f38015048f48 tip

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