Bundle/PageBundle/Helper/PageHelper.php
public function findPageByParameters($parameters)
    {
        if (!empty($parameters['id']) && !preg_match('/^ref_/', $parameters['id'])) {
            $page = $this->entityManager->getRepository('VictoireCoreBundle:View')->findOneBy([
                'id' => $parameters['id'],
            ]);

            $this->checkPageValidity($page, $parameters);
        } else {
            if (isset($parameters['id']) && isset($parameters['locale'])) {
                //if locale is missing, we add append locale
                if (preg_match('/^ref_[0-9]*$/', $parameters['id'])) {
                    $parameters['id'] .= '_'.$parameters['locale'];
                }
            }
            $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters($parameters);
            if ($viewReference === null && !empty($parameters['viewId'])) {
                $parameters['templateId'] = $parameters['viewId'];
                unset($parameters['viewId']);
                $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters($parameters);
            }

            if ($viewReference instanceof ViewReference) {
                $page = $this->findPageByReference($viewReference);
            } else {
                throw new ViewReferenceNotFoundException($parameters);
            }
            $page->setReference($viewReference, $viewReference->getLocale());
        }

        return $page;
    }
public function findPageByParameters($parameters)
    {
        if (!empty($parameters['id']) && !preg_match('/^ref_/', $parameters['id'])) {
            $page = $this->entityManager->getRepository('VictoireCoreBundle:View')->findOneBy([
                'id' => $parameters['id'],
            ]);

            $this->checkPageValidity($page, $parameters);
        } else {
            if (isset($parameters['id']) && isset($parameters['locale'])) {
                //if locale is missing, we add append locale
                if (preg_match('/^ref_[0-9]*$/', $parameters['id'])) {
                    $parameters['id'] .= '_'.$parameters['locale'];
                }
            }
            $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters($parameters);
            if ($viewReference === null && !empty($parameters['viewId'])) {
                $parameters['templateId'] = $parameters['viewId'];
                unset($parameters['viewId']);
                $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters($parameters);
            }

            if ($viewReference instanceof ViewReference) {
                $page = $this->findPageByReference($viewReference);
            } else {
                throw new ViewReferenceNotFoundException($parameters);
            }
            $page->setReference($viewReference, $viewReference->getLocale());
        }

        return $page;
    }
public function findPageByParameters ( $ parameters ) { if ( ! empty ( $ parameters [ 'id' ] ) && ! preg_match ( '/^ref_/' , $ parameters [ 'id' ] ) ) { $ page = $ this -> entityManager -> getRepository ( 'VictoireCoreBundle:View' ) -> findOneBy ( [ 'id' => $ parameters [ 'id' ] , ] ) ; $ this -> checkPageValidity ( $ page , $ parameters ) ; } else { if ( isset ( $ parameters [ 'id' ] ) && isset ( $ parameters [ 'locale' ] ) ) { //if locale is missing, we add append locale if ( preg_match ( '/^ref_[0-9]*$/' , $ parameters [ 'id' ] ) ) { $ parameters [ 'id' ] .= '_' . $ parameters [ 'locale' ] ; } } $ viewReference = $ this -> viewReferenceRepository -> getOneReferenceByParameters ( $ parameters ) ; if ( $ viewReference === null && ! empty ( $ parameters [ 'viewId' ] ) ) { $ parameters [ 'templateId' ] = $ parameters [ 'viewId' ] ; unset ( $ parameters [ 'viewId' ] ) ; $ viewReference = $ this -> viewReferenceRepository -> getOneReferenceByParameters ( $ parameters ) ; } if ( $ viewReference instanceof ViewReference ) { $ page = $ this -> findPageByReference ( $ viewReference ) ; } else { throw new ViewReferenceNotFoundException ( $ parameters ) ; } $ page -> setReference ( $ viewReference , $ viewReference -> getLocale ( ) ) ; } return $ page ; }
Generates a response from parameters.

@param array $parameters

@throws ViewReferenceNotFoundException

@return View
Generates a response from parameters .