sathyashrayan

Blog/Controller/ListController.php

Jul 2nd, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. <?php
  2.  
  3. /*namespace Blog\Controller;
  4.  
  5. use Zend\Mvc\Controller\AbstractActionController;
  6. use Blog\Model\PostRepositoryInterface;
  7. use Zend\View\Model\ViewModel;
  8.  
  9.  
  10. class ListController extends AbstractActionController
  11. {
  12.     private $postRepository;
  13.    
  14.     public function __construct(PostRepositoryInterface $postRepository)
  15.     {
  16.         $this->postRepository = $postRepository;
  17.     }
  18.    
  19.     public function indexAction()
  20.     {
  21.         return new ViewModel([
  22.                 'posts' => $this->postRepository->findAllPosts(),
  23.         ]);
  24.     }
  25. }*/
  26.  
  27.  
  28. //changed
  29. namespace Blog\Controller;
  30.  
  31. use Zend\Mvc\Controller\AbstractActionController;
  32. use Blog\Mapper\PostRepositoryInterface; //changed
  33. use Zend\View\Model\ViewModel;
  34.  
  35.  
  36. class ListController extends AbstractActionController
  37. {
  38.     private $postRepository;
  39.    
  40.     public function __construct(PostRepositoryInterface $postRepository)
  41.     {
  42.         $this->postRepository = $postRepository;
  43.     }
  44.    
  45.     public function indexAction()
  46.     {
  47.         return new ViewModel([
  48.                 'posts' => $this->postRepository->findAllPosts(),
  49.         ]);
  50.     }
  51. }
Add Comment
Please, Sign In to add comment