From 3b87f8575e2f1d91b331d67005d467411e24e969 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 24 Aug 2018 09:37:24 +0200 Subject: [PATCH] Minor - remove unused classes --- .../Controller/BaseResourceController.php | 232 ------------------ .../Controller/RedirectingController.php | 32 --- 2 files changed, 264 deletions(-) delete mode 100644 src/CoreBundle/Controller/BaseResourceController.php delete mode 100644 src/CoreBundle/Controller/RedirectingController.php diff --git a/src/CoreBundle/Controller/BaseResourceController.php b/src/CoreBundle/Controller/BaseResourceController.php deleted file mode 100644 index bd0bcdb1a7..0000000000 --- a/src/CoreBundle/Controller/BaseResourceController.php +++ /dev/null @@ -1,232 +0,0 @@ -container->get('security.context'); - }*/ - - /** - * @return object - */ - public function getTemplate() - { - return $this->container->get('templating'); - } - - /** - * @return NotFoundHttpException - */ - public function abort() - { - return new NotFoundHttpException(); - } - - /** - * Converts string 'Chamilo\CoreBundle\Controller\Admin\QuestionManager' into - * 'admin/question_manager'. - */ - public function getTemplatePath() - { - $parts = $this->classParts; - - $newPath = []; - foreach ($parts as $part) { - if (in_array($part, ['chamilo_lms', 'controller']) - //strpos($part, '_controller') > 0 - ) { - continue; - } - $newPath[] = $part; - } - - $template = implode('/', $newPath); - - return str_replace('_controller', '', $template); - } - - /** - * Transforms 'QuestionManagerController' to 'question_manager.controller'. - * - * @return string - */ - public function getControllerAlias() - { - $parts = $this->classParts; - $parts = array_reverse($parts); - $alias = str_replace('_controller', '.controller', $parts[0]); - - return $alias; - } - - /** - * Translator shortcut. - * - * @param string $variable - * - * @return string - */ - public function trans($variable) - { - return $this->container->get('translator')->trans($variable); - } - - /** - * Returns the class name label. - * - * @example RoleController -> Role - * - * @return string the class name label - */ - public function getClassNameLabel() - { - return $this->classNameLabel; - } - - /** - * @return MenuFactoryInterface - */ - public function getMenuFactory() - { - return $this->container->get('knp_menu.factory'); - } - - /** - * @param $action - * @param MenuItemInterface $menu - * - * @return MenuItemInterface - */ - public function buildBreadcrumbs($action, MenuItemInterface $menu = null) - { - if (!$menu) { - $menu = $this->getHomeBreadCrumb(); - } - - $menu->addChild( - $this->trans($this->getClassnameLabel().'List'), - ['uri' => $this->generateControllerUrl('listingAction')] - ); - - $action = str_replace( - [$this->getControllerAlias().':', 'Action'], - '', - $action - ); - - switch ($action) { - case 'add': - case 'edit': - $menu->addChild( - $this->trans($this->getClassnameLabel().ucfirst($action)) - //array('uri' => $this->generateControllerUrl($action.'Action')) - ); - break; - } - - return $menu; - } - - /** - * Renders the current controller template. - * - * @param string $name - * @param array $elements - * - * @return mixed - */ - public function renderTemplate($name, $elements = []) - { - $name = $this->getTemplatePath().'/'.$name; - - $renderer = new ListRenderer(new \Knp\Menu\Matcher\Matcher()); - $action = $this->getRequest()->get('_route'); - $result = $renderer->render($this->getBreadcrumbs($action)); - $elements['new_breadcrumb'] = $result; - - return $this->getTemplate()->renderTemplate($name, $elements); - } - - /** - * @param string $action - * - * @return MenuItemInterface - */ - protected function getBreadcrumbs($action) - { - $breadcrumbs = $this->buildBreadcrumbs($action); - - return $breadcrumbs; - } - - /** Main home URL - * @return MenuItemInterface - */ - protected function getHomeBreadCrumb() - { - $menu = $this->getMenuFactory()->createItem( - 'root', - [ - 'childrenAttributes' => [ - 'class' => 'breadcrumb', - 'currentClass' => 'active', - ], - ] - ); - - $menu->addChild( - $this->trans('Home'), - ['uri' => $this->generateUrl('home')] - ); - - return $menu; - } - - /** - * @param array $breadCrumbList - * - * @return string - */ - protected function parseLegacyBreadCrumb($breadCrumbList = []) - { - $menu = $this->getHomeBreadCrumb(); - foreach ($breadCrumbList as $item) { - $menu->addChild( - $this->trans($item['title']), - ['uri' => $item['url']] - ); - } - - $renderer = new ListRenderer(new \Knp\Menu\Matcher\Matcher()); - $result = $renderer->render($menu); - - return $result; - } - - /** - * {@inheritdoc} - */ - /*public function isGranted($attributes, $object = null) - { - return $this->get('security.authorization_checker')->isGranted($attributes, $object); - }*/ -} diff --git a/src/CoreBundle/Controller/RedirectingController.php b/src/CoreBundle/Controller/RedirectingController.php deleted file mode 100644 index 7126289158..0000000000 --- a/src/CoreBundle/Controller/RedirectingController.php +++ /dev/null @@ -1,32 +0,0 @@ -getPathInfo(); - if ($pathInfo == '/_trans/') { - return; - } - $requestUri = $request->getRequestUri(); - - $url = str_replace($pathInfo, rtrim($pathInfo, ' /'), $requestUri); - - return $this->redirect($url, 301); - } -}