Sfoglia il codice sorgente

Add plugin (legacy) symfony2 action

jmontoyaa 8 anni fa
parent
commit
94363d4639

+ 1 - 0
app/config/sonata/sonata_page.yml

@@ -23,6 +23,7 @@ sonata_page:
         - ^/administration(.*) # sonata admin
         - ^/admin(.*) # chamilo admin
         - ^/main(.*)
+        - ^/plugin(.*)
         - /(.*)/(.*)administration(.*)/
         - ^/api/(.*)
         - ^/login/(.*)

+ 25 - 21
src/Chamilo/CoreBundle/Controller/LegacyController.php

@@ -22,41 +22,40 @@ class LegacyController extends ToolBaseController
 {
     public $section;
 
+    private function setContainerValuesToLegacy()
+    {
+          /** @var Connection $dbConnection */
+        $dbConnection = $this->container->get('database_connection');
+        $em = $this->get('kernel')->getContainer()->get('doctrine.orm.entity_manager');
+
+        $database = new \Database($dbConnection, array());
+
+        $database->setConnection($dbConnection);
+        $database->setManager($em);
+        Container::$container = $this->container;
+        Container::$dataDir = $this->container->get('kernel')->getDataDir();
+        Container::$courseDir = $this->container->get('kernel')->getDataDir();
+        $this->container->get('twig')->addGlobal('api_get_cidreq', api_get_cidreq());
+    }
+
     /**
+     * Handles all request in old legacy files inside 'main/' folder
      * @param string $name
      * @param Request $request
      * @return Response
      */
-    public function classicAction($name, Request $request)
+    public function classicAction($name, Request $request, $folder = 'main')
     {
         // get.
         $_GET = $request->query->all();
         // post.
         $_POST = $request->request->all();
-
         $rootDir = $this->get('kernel')->getRealRootDir();
-
-        //$_REQUEST = $request->request->all();
-        $mainPath = $rootDir.'main/';
+        $mainPath = $rootDir.$folder.'/';
         $fileToLoad = $mainPath.$name;
 
         // Setting legacy values inside the container
-
-        /** @var Connection $dbConnection */
-        $dbConnection = $this->container->get('database_connection');
-        $em = $this->get('kernel')->getContainer()->get('doctrine.orm.entity_manager');
-
-        $database = new \Database($dbConnection, array());
-
-        $database->setConnection($dbConnection);
-        $database->setManager($em);
-        Container::$container = $this->container;
-        Container::$dataDir = $this->container->get('kernel')->getDataDir();
-        Container::$courseDir = $this->container->get('kernel')->getDataDir();
-        //Container::$configDir = $this->container->get('kernel')->getConfigDir();
-        $this->container->get('twig')->addGlobal('api_get_cidreq', api_get_cidreq());
-
-        //$breadcrumb = $this->container->get('chamilo_core.block.breadcrumb');
+        $this->setContainerValuesToLegacy();
 
         if (is_file($fileToLoad) &&
             \Security::check_abs_path($fileToLoad, $mainPath)
@@ -125,4 +124,9 @@ class LegacyController extends ToolBaseController
             throw new NotFoundHttpException();
         }
     }
+
+    public function pluginAction($name, Request $request)
+    {
+        return $this->classicAction($name, $request, 'plugin');
+    }
 }

+ 16 - 13
src/Chamilo/CoreBundle/Resources/config/routing.yml

@@ -7,21 +7,21 @@ userportal:
     type:     annotation
     prefix:   /userportal
 
-front:
-    resource: '@ChamiloCoreBundle/Controller/FrontController.php'
-    type:     annotation
-    prefix:   /front
+#front:
+#    resource: '@ChamiloCoreBundle/Controller/FrontController.php'
 #    type:     annotation
-user:
-    resource: '@ChamiloCoreBundle/Controller/User/UserController.php'
-    type:     annotation
-    prefix:   /user
-#    prefix:   /userportal
+#    prefix:   /front
+
+#user:
+#    resource: '@ChamiloCoreBundle/Controller/User/UserController.php'
+#    type:     annotation
+#    prefix:   /user
+
 course:
     resource: '@ChamiloCoreBundle/Controller/CourseController.php'
     type:     annotation
     prefix:   /course
-#
+
 legacy_javascript:
     resource: '@ChamiloCoreBundle/Controller/JavascriptLegacyController.php'
     type:     annotation
@@ -34,6 +34,12 @@ main:
     requirements:
       name: .+
 
+legacy_plugin:
+    path: /plugin/{name}
+    defaults: { _controller: ChamiloCoreBundle:Legacy:plugin }
+    requirements:
+      name: .+
+
 # web url shortcuts for legacy templates
 web.ajax:
     path: main/inc/ajax/
@@ -41,9 +47,6 @@ web.ajax:
 web.main:
     path: main/
 
-web.img:
-    path: bundles/chamilocore/img/
-
 # Core controllers
 core_admin:
     resource: '@ChamiloCoreBundle/Controller/Admin'