Beispiel #1
0
 public function renderDefault()
 {
     $this->template->anyVariable = 'any value';
     //		$dao = $this->articles;
     $this->template->articles = $this->articles->getArticles()->findAll();
     $posts = $this->EntityManager->getRepository(Posts::getClassName());
     $this->template->posts = $posts->findAll();
     $this->template->myparametr = $this->context->parameters['first_parametr'];
     //		$this->template->test = $this->doSomeRefactoring('Hello world from blog');
     //		$post = new Posts();
     //		$post->title = 'New title';
     //		$post->text = 'New text New textNew text';
     //		$post->created_at = new \Nette\Utils\DateTime;
     //
     //
     //		$this->EntityManager->persist($post);
     //		$this->EntityManager->flush();
     //		$dao = $this->EntityManager->getRepository(Posts::getClassName());
     //		$dao->setTitle('test');
     //		$dao->__call('set', ['title' => 'my title']);
     //		dump($dao->__isset('title'));
     //		$dao->__set('title', 'test');
     try {
         $this->checkNum(2);
         \Tracy\Debugger::barDump('If you see this, the number is 1 or below');
     } catch (Nette\Application\BadRequestException $e) {
         Debugger::log('Message: ' . $e->getMessage());
         var_dump($e->getMessage());
     }
     //		finally {
     //			\Tracy\Debugger::barDump('Got here Finally');
     //		}
 }
Beispiel #2
0
 public function actionSave()
 {
     $repo = $this->em->getRepository(Posts::getClassName());
     $oPost = $repo->find($this->request->getPost('id'));
     if (is_null($oPost)) {
         $oPost = new Posts();
     }
     $oPost->title = $this->request->getPost('title');
     $oPost->content = $this->request->getPost('content');
     $oPost->intro = strip_tags($this->request->getPost('intro'));
     $oPost->createdAt = $this->request->getPost('created_at') . " 00:00:00";
     $postCover = $this->savePostCover();
     if ($postCover) {
         $oPost->postCover = $postCover;
     }
     $this->em->persist($oPost);
     $this->em->flush();
     $this->flashMessage('Thank you for your comment', 'success');
     $this->redirectUrl('/#/post/' . $oPost->id);
 }