show

@author Tom Haskins-Vaughan <tom@tomhv.uk>
@since  0.8.0

@Template
@ParamConverter("account", class="Phospr\CoreBundle\Entity\Account")

@param  Request $request
777556
public function showAction(Request $request, Account $account)
    {
        $this->get('white_october_breadcrumbs')
            ->addItem('Home',
                $this->get('router')->generate('_homepage')
            )
            ->addItem('Accounts',
                $this->get('router')->generate('phospr_account')
            )
        ;

        $treePath = $this->get('phospr.account_handler')
            ->getTreePath($account)
        ;

        foreach ($treePath as $node) {
            if ($node->getLvl()) {
                $this->get('white_october_breadcrumbs')
                    ->addItem($node->getName(),
                        $this->get('router')->generate('phospr_account_show', array(
                            'path' => $node->getPath()
                    )))
                ;
            }
        }

        $calculatedBalance = 0;

        foreach ($account->getPostings() as $posting) {
            $calculatedBalance += $posting->getAmount();

            $posting->setCalculatedBalance($calculatedBalance);
        }

        $journal = $this->get('phospr.journal_handler')->createJournal();

        $form = $this->createForm(new SimpleJournalType(), $journal);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->get('doctrine')->getManager();

            $amount  = $form->getData()->getCreditAmount();
            $amount -= $form->getData()->getDebitAmount();

            $ph = $this->get('phospr.posting_handler');

            $form->getData()->addPosting($ph->createPosting($account, $amount));
            $form->getData()->addPosting($ph->createPosting(
                $form->getData()->getOffsetAccount(),
                -1*$amount
            ));

            $em->persist($form->getData());
            $em->flush();

            return $this->redirect($this->generateUrl(
                'phospr_account_show', array('path' => $account->getPath())
            ));
        }

        return array(
            'account' => $account,
            'form'    => $form->createView(),
        );
    }
283686
public function show(Request $request, $user)
    {
        // Set roles that have access
        $request->user()->authorizeRoles(['admin']);

        // Return view with user object
        $user = User::findOrFail($user);
        return view('user::show', ['user' => $user]);
    }
75419
public function showAction(Request $request, $id)
    {
        /** @var ConfiguratorFactory $configuratorFactory */
        $configuratorFactory = $this->getConfiguratorFactory($this->getClassName());
        /** @var CrudConfigurator $crudConfigurator */
        $crudConfigurator = $configuratorFactory->getConfigurator(CrudConfigurator::class);
        /* @var PageConfigurator $pageConfigurator */
        $pageConfigurator = $configuratorFactory->getConfigurator(PageConfigurator::class);
        /* @var GridConfigurator $gridConfigurator */
        $gridConfigurator = $configuratorFactory->getConfigurator(GridConfigurator::class);

        $this->isGrantedOr404Error($crudConfigurator, Constants::ACTION_READ);
        $crud = $crudConfigurator->getCrud();

        $translator = $this->get('translator');
        $translationDomain = $this->getParameter('symfonyid.admin.translation_domain');
        /** @var ModelInterface $model */
        $model = $this->findOr404Error($id);
        /** @var View $view */
        $view = $this->get('symfonyid.admin.view.view');
        $view->setParam('page_title', $translator->trans($pageConfigurator->getTitle(), array(), $translationDomain));
        $view->setParam('page_description', $translator->trans($pageConfigurator->getDescription(), array(), $translationDomain));

        $driver = $this->get('symfonyid.admin.manager.driver_finder')->findDriverForClass($crud->getModelClass());
        $crudFactory = $this->get('symfonyid.admin.crud.crud_factory');
        $crudFactory->setRequest($request);
        $crudFactory->setDriver($driver);
        $crudFactory->setView($view);
        $crudFactory->setTemplate($crudConfigurator->getTemplate()->getShow());
        $showFields = $crud->getShowFields() ?: $gridConfigurator->getColumns(new \ReflectionClass($crud->getModelClass()));

        return $crudFactory->showDetail($model, $showFields, $crud->isAllowDelete());
    }
1075037
public function cgetAction(Request $request)
    {
        $locale = $this->getRequestParameter($request, 'locale', true);
        $list = new CollectionRepresentation(
            $this->getManager()->findAllByLocale($locale),
            self::$entityKey
        );

        $view = $this->view($list, 200);

        return $this->handleView($view);
    }
657091
public function setRequest(Request $request)
    {
        $this->issuer->setRequest($request);
        $this->checker->setRequest($request);
    }
1002818
public function send(?Request $request = null) {
        $request = self::validateRequest($request);

        $this->
            render($request)->
            prepare($request)->
            send();
    }
483630
public function showDataChartAction(Request $request, User $eleve)
    {
        $this->checkOpenPrintPdf($request);
        $json = $this->totauxManager->getDataChart($eleve, true);
        $jsonNoCeb = $this->totauxManager->getDataChart($eleve, false);

        return $this->render(
            'LaurentBulletinBundle::BulletinShowDataChart.html.twig',
            array('json' => $json, 'jsonNoCeb' => $jsonNoCeb, 'eleve' => $eleve)
        );
    }
954374
public function showAction(Request $request, $id = 1)
    {

        $resource = $this->findOr404('find', array($id));

        $this->dispatch(Actions::SHOW, $resource);

        return $this->render($this->getFromConfig($request, 'template', true), array(
            $this->name => $resource
        ));
    }
531358
public function showAction(Request $request, $instance, $homeFolder)
    {
        $efParameters = $this->container->getParameter('fm_elfinder');

        if (empty($efParameters['instances'][$instance])) {
            throw new NotFoundHttpException('Instance not found');
        }
        $parameters   = $efParameters['instances'][$instance];

        if (empty($parameters['locale'])) {
            $parameters['locale'] = $request->getLocale();
        }

        $assetsPath   = $efParameters['assets_path'];
        $result       = $this->selectEditor($parameters, $instance, $homeFolder, $assetsPath, $request->get('id'));

        return $this->render($result['template'], $result['params']);
    }
920023
public function show(Request $request)
    {
        $category = $this->api('category.fetch', $request->route('category'))->get();

        event(new UserViewingCategory($category));

        $categories = [];
        if (Gate::allows('moveCategories')) {
            $categories = $this->api('category.index')->parameters(['where' => ['category_id' => 0]])->get();
        }

        $threads = $category->threadsPaginated;

        return view('forum::category.show', compact('categories', 'category', 'threads'));
    }
688812
public function postAction(Request $request)
    {
        $targetGroup = $this->deserializeData($request->getContent());
        $targetGroup = $this->getTargetGroupRepository()->save($targetGroup);

        $this->getEntityManager()->flush();

        return $this->handleView($this->view($targetGroup));
    }
890758
public function indexAction(Request $request)
    {
        $this->get('white_october_breadcrumbs')
            ->addItem('Home', $this->get('router')->generate('_homepage'))
            ->addItem('Accounts', $this->get('router')->generate('phospr_account'))
        ;

        $em = $this->get('doctrine')->getManager();
        $ah = $this->get('phospr.account_handler');

        $form = $this->createFormBuilder($ah->createAccount())
            ->add('parent', 'account_selector')
            ->add('name')
            ->add('save', 'submit', array('label' => 'Create Account'))
            ->getForm()
        ;

        $form->handleRequest($request);

        if ($form->isValid()) {
            try {
                $em->persist($form->getData());
                $em->flush();
            } catch (\Doctrine\DBAL\DBALException $e) {
                exit(sprintf(
                    'Account %s already exists',
                    $form->getData()->getSegmentation()
                ));
            }

            return $this->redirect($this->generateUrl('phospr_account'));
        }


        $criteria = new Criteria();
        $criteria
            ->where($criteria->expr()->eq(
                'organization',
                $this->get('phospr.organization_handler')->getOrganization()
            ))
            ->andWhere($criteria->expr()->gt('lvl', 0))
            ->orderBy(array('lft' => Criteria::ASC))
        ;

        $accounts = $em->getRepository('PhosprCoreBundle:Account')
            ->matching($criteria)
        ;

        if ('json' == $request->getRequestFormat()) {
            $accountsArray = array();

            foreach ($accounts as $account) {
                if (1 < $account->getLvl()) {
                    $vendorsArray[] = array(
                      'label'         => $account->getSegmentation(),
                      'value'         => $account->getSegmentation(),
                    );
                }
            }

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

            return $response;
        }

        return array(
            'accounts' => $accounts,
            'form'     => $form->createView(),
        );
    }
457415
public function render(Request $request = null): Response
    {
        return new Response(static::generateView($this->getMessage()), $this->getCode());
    }
252189
public function showAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        /* @var $rep NoticeRepository */
        $rep = $em->getRepository('AnimeDbAppBundle:Notice');

        $notice = $rep->getFirstShow();
        // caching
        /* @var $response JsonResponse */
        $response = $this->getCacheTimeKeeper()->getResponse([], -1, new JsonResponse());
        $response->setEtag(md5($notice ? $notice->getId() : 0));
        // response was not modified for this request
        if ($response->isNotModified($request)) {
            return $response;
        }

        // shown notice
        if (!is_null($notice)) {
            $notice->shown();
            $em->persist($notice);
            $em->flush();

            $response->setData([
                'notice' => $notice->getId(),
                'close' => $this->generateUrl('notice_close', ['id' => $notice->getId()]),
                'see_later' => $this->generateUrl('notice_see_later'),
                'content' => $this->renderView('AnimeDbAppBundle:Notice:show.html.twig', [
                    'notice' => $notice,
                    'link_all' => $request->query->getBoolean('all'),
                ]),
            ]);
        }

        return $response;
    }
680257
public function listAction(Request $request)
    {
        $this->denyAccessUnlessGranted(ContributionActionInterface::READ, UserInterface::ENTITY_TYPE);
        $mapping = array(
            'username' => 'username',
            'groups' => 'groups.label'
        );
        $configuration = PaginateFinderConfiguration::generateFromRequest($request, $mapping);
        $repository = $this->get('open_orchestra_user.repository.user');
        $language = $this->get('open_orchestra_backoffice.context_backoffice_manager')->getBackOfficeLanguage();

        if ($this->get('security.authorization_checker')->isGranted(ContributionRoleInterface::PLATFORM_ADMIN)) {
            $collection = $repository->findForPaginate($configuration, $language);
            $recordsTotal = $repository->count();
            $recordsFiltered = $repository->countWithFilter($configuration, $language);
        } else {
            $sitesId = $this->getAvailableSiteIds();
            $collection = $repository->findForPaginateFilterBySiteIds($configuration, $language, $sitesId);
            $recordsTotal = $repository->countFilterBySiteIds($sitesId);
            $recordsFiltered = $repository->countWithFilterAndSiteIds($configuration, $language, $sitesId);
        }

        $facade = $this->get('open_orchestra_api.transformer_manager')->transform('user_collection', $collection);
        $facade->recordsTotal = $recordsTotal;
        $facade->recordsFiltered = $recordsFiltered;

        return $facade;
    }
24214
public function show($date, Request $request)
    {
        $level   = 'all';
        $log     = $this->getLogOrFail($date);
        $query   = $request->get('query');
        $levels  = $this->logViewer->levelsNames();
        $entries = $log->entries($level)->paginate($this->perPage);

        return $this->view('show', compact('level', 'log', 'query', 'levels', 'entries'));
    }
1027690
public function show($id, ShowRequest $request)
    {
        $user = $this->repository->findWithoutFail($id);
        $user->load($request->getWith());

        if (empty($user)) {
            return $this->sendError('User not found');
        }

        return $this->sendResponse($user, '');
    }