Display page to get some details on a appbox

@param  Request $request    The current HTTP request
@param  integer $databox_id The requested databox
@return Response
762179
public function getDetails(Request $request, $databox_id)
    {
        $databox = $this->findDataboxById($databox_id);

        $details = [];
        $total = ['total_subdefs' => 0, 'total_size' => 0];

        foreach ($databox->get_record_details($request->query->get('sort')) as $collName => $colDetails) {
            $details[$collName] = [
                'total_subdefs' => 0,
                'total_size' => 0,
                'medias' => []
            ];

            foreach ($colDetails as $subdefName => $subdefDetails) {
                $details[$collName]['total_subdefs'] += $subdefDetails['n'];
                $total['total_subdefs'] += $subdefDetails['n'];
                $details[$collName]['total_size'] += $subdefDetails['siz'];
                $total['total_size'] += $subdefDetails['siz'];

                $details[$collName]['medias'][] = [
                    'subdef_name' => $subdefName,
                    'total_subdefs' => $subdefDetails['n'],
                    'total_size' => $subdefDetails['siz'],
                ];
            }
        }

        return $this->render('admin/databox/details.html.twig', [
            'databox' => $databox,
            'table'   => $details,
            'total'   => $total
        ]);
    }
235480
public function showAction(Request $request, $access, $id)
    {
        $em = $this->getDoctrineManager();
        // Hack. The contextGetAction in CommonBundle is not as smart as it
        // looks.
        $message = null;
        if ($id instanceof Message) {
            $message = $id;
        } elseif (is_numeric($id)) {
            $message = $em->getRepository('BisonLabSakonninBundle:Message')
                    ->find($id);
        } else {
            $message = $em->getRepository('BisonLabSakonninBundle:Message')
                    ->findOneBy(array('message_id' => $id));
        }
        if (!$message) {
            return $this->returnNotFound($request, 'Unable to find Message.');
        }
        $this->denyAccessUnlessGranted('show', $message);
        // If it's shown to receiver, it's read.
        $sm = $this->container->get('sakonnin.messages');
        $user = $this->getUser();
        // Not sure I want to set READ automatically. But UNREAD/READ is not
        // archived, which the users should set themselves.
        if ($message->getTo() == $user->getId()) {
            $message->setState("READ");
            $em = $this->getDoctrineManager();
            $em->flush();
        }
        if ($this->isRest($access)) {
            return $this->returnRestData($request, $messages, array('html' =>'BisonLabSakonninBundle:Message:_show.html.twig'));
        }
        return $this->render('BisonLabSakonninBundle:Message:show.html.twig',
            array('entity' => $message));
    }
862863
public function previewAction(Request $request, DataInterface $data)
    {
        return $this->editAction($request, $data, $data->getFamily());
    }
1368005
public function showEdit(int $id = null, array $request = [])
    {
        if ($id === null) {
            if (isset($_GET['template']) === false) {
                return redirect($this->router->generate('pages-list-page') . "?m=2");
            } else {
                return 'Redirect: ' . $this->router->generate('pages-list-page') . "?m=2";
            }
        }
        $page = $this->core->api('Page/' . $id, 'GET')->run();
        if ($page['headers'][0][2] === 422) {
            if (isset($_GET['template']) === false) {
                return redirect($this->router->generate('pages-list-page') . "?m=2");
            } else {
                return 'Redirect: ' . $this->router->generate('pages-list-page') . "?m=2";
            }
        } elseif (($page["headers"][0][2] - 200) * ($page["headers"][0][2] - 299) > 0) {
            if (headers_sent() === false) {
                foreach ($page["headers"] as $header) {
                    header($header[0], $header[1], $header[2]);
                }
            }
            return $this->templates->render("500", [
                "error" => $page['response'],
                "result" => ''
            ]);
        }

        $messages = [
            'error' => '',
            'info' => '',
            'success' => '',
            'warning' => ''
        ];
        if (empty($request['m']) === false) {
            if ($request['m'] == 1) {
                $messages['success'] = 'Page created successfully.';
            }
        }

        $pages_list = $this->core->api('Page/all', 'GET')->run();
        return $this->templates->render("Main::Pages/Edit", [
            "messages" => $messages,
            "page" => $page['response'],
            "pages" => $pages_list['response']
        ]);
    }
1027597
public function detailAction($id, Request $request)
    {
        $record = $this->findNode($id);

        return $this->renderTemplate($record, $request);
    }
1372434
public function reindex(Request $request, $databox_id)
    {
        $success = false;

        try {
            $this->findDataboxById($databox_id)->reindex();
            $success = true;
        } catch (\Exception $e) {

        }

        if ('json' === $request->getRequestFormat()) {
            return $this->app->json([
                'success' => $success,
                'msg'     => $success ? $this->app->trans('Successful update') : $this->app->trans('An error occured'),
                'sbas_id' => $databox_id,
            ]);
        }

        return $this->app->redirectPath('admin_database', [
            'databox_id' => $databox_id,
            'success'    => (int) $success,
        ]);
    }
592345
public function publishAction(Request $request, $id = null)
    {
        $id = $request->get($this->admin->getIdParameter());

        $object = $this->admin->getObject($id);

        if (!$object) {
            throw new NotFoundHttpException(sprintf('unable to find the object with id : %s', $id));
        }

        if (false === $this->admin->isGranted('PUBLISH', $object)) {
            throw new AccessDeniedException();
        }

        $this->admin->setSubject($object);

        $form = $this->admin->getForm();

        $object->setStatus(PageInterface::STATUS_PUBLISHED);

        // persist if the form was valid and if in preview mode the preview was approved
        $this->admin->update($object);

        if ($object->getStatus() == PageInterface::STATUS_PUBLISHED) {
            $this->makeSnapshot($object);
        }

        $request->getSession()->getFlashBag()->add(
            'sonata_flash_success',
            $this->translate('flash_publish_success')
        );

        return $this->redirect($this->admin->generateObjectUrl('edit', $object));
    }
1336670
public function show($id,Request $request)
    {
        if($request->ajax())
        {
            return URL::to('package/'.$id);
        }

        $package = Package::findOrfail($id);
        return view('unstarter.package.show',compact('package'));
    }
965849
public function indexDataAction(Request $request)
        {

            $aRemoteApps = RemoteAppQuery::create()->find();
            $sResult     = $this->renderView('SlashworksAppBundle:RemoteApp:data.json.twig', array(
                'entities' => $aRemoteApps,
            ));

            $response = new Response($sResult);
            $response->headers->set('Content-Type', 'application/json');

            return $response;

        }
1245185
public function getAction($id, Request $request)
    {
        if ($this->getBooleanRequestParameter($request, 'tree', false, false)) {
            $collections = $this->getCollectionManager()->getTreeById(
                $id,
                $this->getRequestParameter($request, 'locale', true)
            );

            return $this->handleView(
                $this->view(
                    new CollectionRepresentation($collections, 'collections')
                )
            );
        }

        try {
            $locale = $this->getRequestParameter($request, 'locale', true);
            $depth = intval($request->get('depth', 0));
            $breadcrumb = $this->getBooleanRequestParameter($request, 'breadcrumb', false, false);
            $children = $this->getBooleanRequestParameter($request, 'children', false, false);
            $collectionManager = $this->getCollectionManager();

            // filter children
            $listRestHelper = $this->get('sulu_core.list_rest_helper');
            $limit = $request->get('limit', null);
            $offset = $this->getOffset($request, $limit);
            $search = $listRestHelper->getSearchPattern();
            $sortBy = $request->get('sortBy');
            $sortOrder = $request->get('sortOrder', 'ASC');

            $filter = [
                'limit' => $limit,
                'offset' => $offset,
                'search' => $search,
            ];

            $view = $this->responseGetById(
                $id,
                function($id) use ($locale, $collectionManager, $depth, $breadcrumb, $filter, $sortBy, $sortOrder, $children) {
                    $collection = $collectionManager->getById(
                        $id,
                        $locale,
                        $depth,
                        $breadcrumb,
                        $filter,
                        null !== $sortBy ? [$sortBy => $sortOrder] : [],
                        $children
                    );

                    if (SystemCollectionManagerInterface::COLLECTION_TYPE === $collection->getType()->getKey()) {
                        $this->get('sulu_security.security_checker')->checkPermission(
                            'sulu.media.system_collections',
                            PermissionTypes::VIEW
                        );
                    }

                    return $collection;
                }
            );
        } catch (CollectionNotFoundException $cnf) {
            $view = $this->view($cnf->toArray(), 404);
        } catch (MediaException $e) {
            $view = $this->view($e->toArray(), 400);
        }

        return $this->handleView($view);
    }
1143954
public function showEdit(int $id = null, array $request = [])
    {
        if ($id === null) {
            if (isset($_GET['template']) === false) {
                return redirect($this->router->generate('users-list-page') . "?m=2");
            } else {
                return 'Redirect: ' . $this->router->generate('users-list-page') . "?m=2";
            }
        } elseif ($id === $this->core->auth()->details->id) {
            if (isset($_GET['template']) === false) {
                return redirect($this->router->generate('users-list-page') . "?m=3");
            } else {
                return 'Redirect: ' . $this->router->generate('users-list-page') . "?m=3";
            }
        }
        $user = $this->core->api('User/' . $id, 'GET')->run();
        if ($user['headers'][0][2] === 422) {
            if (isset($_GET['template']) === false) {
                return redirect($this->router->generate('users-list-page') . "?m=2");
            } else {
                return 'Redirect: ' . $this->router->generate('users-list-page') . "?m=2";
            }
        } elseif (($user["headers"][0][2] - 200) * ($user["headers"][0][2] - 299) > 0) {
            if (headers_sent() === false) {
                foreach ($user["headers"] as $header) {
                    header($header[0], $header[1], $header[2]);
                }
            }
            return $this->templates->render("500", [
                "error" => $user['response'],
                "result" => ''
            ]);
        }
        $roles_list = $this->core->api('Role/all', 'GET')->run();

        $messages = [
            'error' => '',
            'info' => '',
            'success' => '',
            'warning' => ''
        ];
        if (empty($request['m']) === false) {
            if ($request['m'] == 1) {
                $messages['success'] = 'User registered successfully.';
            } elseif ($request['m'] == 2) {
                if (headers_sent() === false) {
                    header('X-PHP-Response-Code: 202', true, 202);
                }
                $messages['success'] = 'User sessions invalidated successfully.';
            }
        }

        return $this->templates->render("Main::Users/Edit", [
            "messages" => $messages,
            "user" => $user['response'],
            "roles" => $roles_list['response']
        ]);
    }
413180
public function unmountDatabase(Request $request, $databox_id)
    {
        $success = false;

        try {
            $databox = $this->findDataboxById($databox_id);
            $databox->unmount_databox();

            $success = true;
        } catch (\Exception $e) {

        }

        if ('json' === $request->getRequestFormat()) {
            $msg = $success
                ? $this->app->trans('The publication has been stopped')
                : $this->app->trans('An error occured');
            return $this->app->json([
                'success' => $success,
                'msg'     => $msg,
                'sbas_id' => $databox_id
            ]);
        }

        return $this->app->redirectPath('admin_databases', [
            'reload-tree' => 1,
        ]);
    }
401471
public function deleteBase(Request $request, $databox_id)
    {
        $databox = null;
        $success = false;
        $msg = $this->app->trans('An error occured');
        try {
            $databox = $this->findDataboxById($databox_id);

            if ($databox->get_record_amount() > 0) {
                $msg = $this->app->trans('admin::base: vider la base avant de la supprimer');
            } else {
                $databox->unmount_databox();
                $this->getApplicationBox()->write_databox_pic(
                    $this->app['media-alchemyst'],
                    $this->app['filesystem'],
                    $databox,
                    null,
                    \databox::PIC_PDF
                );
                $databox->delete();
                $success = true;
                $msg = $this->app->trans('Successful removal');
            }
        } catch (\Exception $e) {

        }
        if (!$databox) {
            $this->app->abort(404, $this->app->trans('admin::base: databox not found', ['databox_id' => $databox_id]));
        }

        if ('json' === $request->getRequestFormat()) {
            return $this->app->json([
                'success' => $success,
                'msg'     => $msg,
                'sbas_id' => $databox->get_sbas_id()
            ]);
        }

        $params = [
            'databox_id' => $databox->get_sbas_id(),
            'success'    => (int) $success,
        ];

        if ($databox->get_record_amount() > 0) {
            $params['error'] = 'databox-not-empty';
        }

        return $this->app->redirectPath('admin_database', $params);
    }
126165
public function getAction($id, Request $request)
    {
        try {
            $locale = $this->getRequestParameter($request, 'locale', true);
            $mediaManager = $this->getMediaManager();
            $view = $this->responseGetById(
                $id,
                function($id) use ($locale, $mediaManager) {
                    $media = $mediaManager->getById($id, $locale);
                    $collection = $media->getEntity()->getCollection();

                    if (SystemCollectionManagerInterface::COLLECTION_TYPE === $collection->getType()->getKey()) {
                        $this->getSecurityChecker()->checkPermission(
                            'sulu.media.system_collections',
                            PermissionTypes::VIEW
                        );
                    }

                    $this->getSecurityChecker()->checkPermission(
                        new SecurityCondition(
                            $this->getSecurityContext(),
                            $locale,
                            $this->getSecuredClass(),
                            $collection->getId()
                        ),
                        PermissionTypes::VIEW
                    );

                    return $media;
                }
            );
        } catch (MediaNotFoundException $e) {
            $view = $this->view($e->toArray(), 404);
        } catch (MediaException $e) {
            $view = $this->view($e->toArray(), 400);
        }

        return $this->handleView($view);
    }
1145186
public function getStoryEmbedAction(Request $request, $databox_id, $record_id)
    {
        $record = $this->findDataboxById($databox_id)->get_record($record_id);

        $devices = $request->get('devices', []);
        $mimes = $request->get('mimes', []);

        $ret = array_values(array_filter(array_map(function ($media) use ($request, $record) {
            return $this->listEmbeddableMedia($request, $record, $media);
        }, $record->get_embedable_medias($devices, $mimes))));

        return Result::create($request, ["embed" => $ret])->createResponse();
    }
1353136
public function show(Request $request, $id)
    {
        // Set roles that have access
        $request->user()->authorizeRoles(['admin']);

        $pagetype = PageType::findOrFail($id);
        $fields = $pagetype->fields;
        return view('page::pagetypes.show', ['pagetype' => $pagetype, 'fields' => $fields]);
    }
201079
public function updateDatabaseCGU(Request $request, $databox_id)
    {
        $databox = $this->findDataboxById($databox_id);

        try {
            foreach ($request->request->get('TOU', []) as $loc => $terms) {
                $databox->update_cgus($loc, $terms, !!$request->request->get('valid', false));
            }
        } catch (\Exception $e) {
            return $this->app->redirectPath('admin_database_display_cgus', [
                'databox_id' => $databox_id,
                'success'    => 0,
            ]);
        }

        return $this->app->redirectPath('admin_database_display_cgus', [
            'databox_id' => $databox_id,
            'success'    => 1,
        ]);
    }