Beispiel #1
0
 /**
  * Creates a new widget based on the request paramaters, or throws an
  * exception on error.
  * @param Website $website The website object.
  * @param Request $request The request.
  * @return PlacedWidget A new widget, still needs to be saved in the database.
  * @throws NotFoundException If the document or widget type in the request
  * is non-existant.
  */
 private function getNewWidget(Website $website, Request $request)
 {
     $directoryName = $request->getRequestString("directory_name", "");
     if ($directoryName === "") {
         throw new NotFoundException();
     }
     // Get document
     $documentRepo = new DocumentRepository($website->getDatabase(), true);
     $documentId = $request->getRequestInt("document_id", 0);
     $document = $documentRepo->getDocumentOrWidgetArea($website->getWidgets(), $website->getText(), $documentId);
     return PlacedWidget::newPlacedWidget($website->getUriWidgets(), $directoryName, $document);
 }
Beispiel #2
0
 private function retrieveDocument(Website $website, DocumentRepository $documentRepo, $id, User $user)
 {
     if ($id === 0) {
         // New document
         return Document::createNew("", "", $user);
     }
     return $documentRepo->getDocumentOrWidgetArea($website->getWidgets(), $website->getText(), $id);
 }