If the page is not valid, an exception is thrown.

@param mixed $page
@param mixed $parameters

@throws \Exception
196745
public function checkPageValidity($page, $parameters = null)
    {
        $entity = null;
        $errorMessage = 'The page was not found';
        if ($parameters) {
            $errorMessage .= ' for parameters "'.implode('", "', $parameters).'"';
        }
        $isPageOwner = false;

        //there is no page
        if ($page === null) {
            throw new NotFoundHttpException($errorMessage);
        }

        if ($this->tokenStorage->getToken()) {
            $isPageOwner = $this->authorizationChecker->isGranted('PAGE_OWNER', $page);
        }

        //a page not published, not owned, nor granted throw an exception
        if (($page instanceof BasePage && !$page->isPublished()) && !$isPageOwner) {
            throw new NotFoundHttpException($errorMessage);
        }

        //if the page is a BusinessTemplate and the entity is not allowed for this page pattern
        if ($page instanceof BusinessTemplate) {
            //only victoire users are able to access a business page
            if (!$this->authorizationChecker->isGranted('ROLE_VICTOIRE')) {
                throw new AccessDeniedException('You are not allowed to see this page');
            }
        } elseif ($page instanceof BusinessPage) {
            $entity = $page->getBusinessEntity();
            if (!$entity->isVisibleOnFront() && !$this->authorizationChecker->isGranted('ROLE_VICTOIRE')) {
                throw new NotFoundHttpException('The BusinessPage for '.get_class($entity).'#'.$entity->getId().' is not visible on front.');
            }
            if (!$page->getId()) {
                $entityAllowed = $this->businessPageHelper->isEntityAllowed($page->getTemplate(), $entity, $this->entityManager);

                if ($entityAllowed === false) {
                    throw new NotFoundHttpException('The entity ['.$entity->getId().'] is not allowed for the page pattern ['.$page->getTemplate()->getId().']');
                }
            }
        }

        if (!$this->authorizationChecker->isGranted('ROLE_VICTOIRE')) {
            $roles = $this->getPageRoles($page);
            if ($roles && !$this->authorizationChecker->isGranted($roles, $entity)) {
                throw new AccessDeniedException('You are not allowed to see this page, see the access roles defined in the view or its parents and templates');
            }
        }
    }
94378
protected function formatExceptionParams($message, $parameters)
    {
        if (trim($message) === '' || $parameters === null) {
            return $message;
        }

        if (is_array($parameters) === false) {
            $parameters = [$parameters];
        }

        return @vsprintf($message, $parameters);
    }
1004443
public function revokePagePrivileges(Page $page)
    {
        if ($this->revokePageStatement == null) {
            $this->revokePageStatement =
                $this->connection->prepare("DELETE FROM UserPrivileges WHERE username = ? AND pageId = ?");
        }
        $this->revokePageStatement->execute(array($this->user->getUsername(), $page->getID()));
        unset($this->pagePrivilege[$page->getID()]);
    }
270514
public function iShouldBeOnThePage($page)
    {
        $url = $this->generateUrl($this->routeMap[$page]);
        $this->assertSession()->addressEquals($url);
        $this->assertStatusCodeEquals(200);
    }
41160
public function deactivatePage(Page $page)
    {

        if (!$this->isActive($page)) {
            return;
        }
        $this->deactivatePageId($page->getID());


    }
484192
public function setPage($page) {
        if (!is_numeric($page)) {
            $page = self::DEFAULT_PAGE;
        }

        if (0 == $page) {
            $page = self::DEFAULT_PAGE;
        }

        $this->page = $page;

        return $this;
    }
1091764
public function handle(\ReflectionParameter $parameter)
    {
        $class = $parameter->getDeclaringClass();
        $className = $class->implementsInterface(WeavedInterface::class) ? $class->getParentClass()->getName() : $class->name;
        $method = $parameter->getDeclaringFunction()->name;
        $msg = sprintf('$%s in %s::%s()', $parameter->name, $className, $method);

        throw new ParameterException($msg, Code::BAD_REQUEST);
    }
514046
public function setParameters($parameters)
    {
        parent::setParameters($parameters);
        if ($parameters !== null) {
            for ($i = 0, $size = count($parameters); $i < $size; $i++) {
                $paramname = $parameters[$i]->getName();
                switch (strtolower($paramname)) {
                    case self::MIN_KEY:
                        $this->setMin($parameters[$i]->getValue());
                        break;
                    case self::MAX_KEY:
                        $this->setMax($parameters[$i]->getValue());
                        break;

                    default:
                        $this->setError("Invalid parameter " . $paramname);
                } // switch
            }
        }
    }
5577
public function render($page, array $params = null)
    {
        $this->setFile($page);

        try {
            if (! file_exists($file = $this->getFile())) {
                throw new NotFoundException("Template file couldn't be found: " . $file);
            }

            if (! empty($params)) {
                $this->assign($params);
            }
            
            $template = $this->tryCompile($file);
        } catch (Exception $e) {
            $this->flushSections();

            $this->dispatchEvent('exception', $e);

            throw $e;
        } catch (Throwable $e) {
            $this->flushSections();

            $this->dispatchEvent('fatal.error', $e);

            throw $e;
        } finally {
            $this->renderingCompleted(function () {
                $this->dispatchEvent('rendering.completed');

                $this->flushSections();

                $this->onEventEmitterEnabled(function ($emitter) {
                    $emitter->removeAllListeners();
                });

                unset($this->vars, $this->shared, $this->customDirectives); // Free the memory
            });
        }

        return $template;
    }
617208
public static function add($route, $parameters)
    {
        self::$route = $route;
        array_shift($parameters);
        self::$parameters = $parameters;
    }
1143363
public function setPage(Page $page)
    {
        $this->page = $page;
        $revision = $page->getCurrentRevision();
        if (empty($revision)) {
            $revision = $page->getPublishedRevision();
        }
        $revisionId = null;
        if (!empty($revision)) {
            $revisionId = $revision->getRevisionId();
        }
        $this->setRevisionId($revisionId);
        $this->setTitle($page->getPageTitle());
        $this->setPageId($page->getPageId());
    }
1119807
public void removeErrorPage(PageException pe) {
	// exception
	ErrorPage ep = getErrorPage(pe, ErrorPage.TYPE_EXCEPTION);
	if (ep != null) {
	    pages.remove(ep);
	    hasChanged = true;
	}
	// request
	ep = getErrorPage(pe, ErrorPage.TYPE_REQUEST);
	if (ep != null) {
	    pages.remove(ep);
	    hasChanged = true;
	}
	// validation
	ep = getErrorPage(pe, ErrorPage.TYPE_VALIDATION);
	if (ep != null) {
	    pages.remove(ep);
	    hasChanged = true;
	}

    }
846463
public function setPage($page = null)
    {
        // The following argument formats are supported:
        //
        // null = set current page
        // '.' = set current page
        // 'page' = sets webroot/page.html
        // './page' = set page relatively to current page
        // '..' = parent page
        // '../page' = page besides our own (foo/bar -> foo/page)
        // 'index' = properly points to the index page defined in APP
        // '/admin/' = will not be converted

        /** @type $this->app App_Web */

        $destination = '';

        if (is_null($page)) {
            $page = '.';
        }

        foreach (explode('/', $page) as $component) {
            if ($component == '') {
                continue;
            }
            if ($component == '.' && $destination == '') {
                if ($this->app->page == 'index') {
                    continue;
                }
                $destination = str_replace('_', '/', $this->app->page);
                continue;
            }

            if ($component == '..') {
                if (!$destination) {
                    $destination = str_replace('_', '/', $this->app->page);
                }
                $tmp = explode('/', $destination);
                array_pop($tmp);
                $destination = implode('/', $tmp);
                continue;
            }

            if ($component == 'index' && $destination == '') {
                $destination = $this->app->index_page;
                continue;
            }

            $destination = $destination ? $destination.'/'.$component : $component;
        }
        if ($destination === '') {
            $destination = @$this->app->index_page;
        }

        $this->page = $destination;

        // check if it's current page
        list($p, $ap) = str_replace('/', '_', array($this->page, $this->app->page));
        $this->_current = ($p == $ap); // page exactly match
        $this->_current_sub = ($p == substr($ap, 0, strlen($p)) && isset($ap[strlen($p)]) && $ap[strlen($p)] == '_'); // first part of page match followed by separator

        return $this;
    }
479426
public function parseParameters($parameters) {
        for($i = 0; $i < count($this->controls); $i++) {
            $this->controls[$i] = $this->parseParameterControl($this->controls[$i], $parameters);
        }
    }
1145366
public function page($page)
    {
        $page = (int)$page;

        if($page<0){
            throw new \RuntimeException('Invalid page specified', ResourceException::INVALID_PAGE);
        }

        $this->page = $page;

        return $this;
    }
437598
protected function requestPagSeguroAbandoned($page)
    {

        $date = $this->getDates();

        $options = [
            'initial_date' => $date['initial'],
            'final_date' => $date['final'],
            'page' => $page,
            'max_per_page' => 1000,
        ];

        try {

            $this->_library->setEnvironment();
            $this->_library->setCharset();
            $this->_library->setLog();

            return \PagSeguro\Services\Transactions\Search\Abandoned::search(
                $this->_library->getPagSeguroCredentials(),
                $options
            );

        } catch (Exception $exception) {
            throw $exception;
        }
    }
702090
protected function pdoException(string $query, array $params) : void
    {
        $this->createException($this->pdo->errorInfo()[2], $query, $params);
    }