public function createFromPage($page, $contents = null) { $page = $this->pageStack->getPage($page); if (!$page) { throw new \InvalidArgumentException('Can not find page.'); } $this->pageStack->setCurrentPage($page); $pageResponse = new PageResponse('', 200, [], $this->pageStack, $this->jarves, $this->stopwatch, $this->assetCompilerContainer, $this->eventDispatcher, $this->templating, $this->editMode); $this->pageStack->setPageResponse($pageResponse); if (null !== $contents) { $pageResponse->setPageContent($contents); } return $pageResponse; }