Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*namespace Blog\Controller;
- use Zend\Mvc\Controller\AbstractActionController;
- use Blog\Model\PostRepositoryInterface;
- use Zend\View\Model\ViewModel;
- class ListController extends AbstractActionController
- {
- private $postRepository;
- public function __construct(PostRepositoryInterface $postRepository)
- {
- $this->postRepository = $postRepository;
- }
- public function indexAction()
- {
- return new ViewModel([
- 'posts' => $this->postRepository->findAllPosts(),
- ]);
- }
- }*/
- //changed
- namespace Blog\Controller;
- use Zend\Mvc\Controller\AbstractActionController;
- use Blog\Mapper\PostRepositoryInterface; //changed
- use Zend\View\Model\ViewModel;
- class ListController extends AbstractActionController
- {
- private $postRepository;
- public function __construct(PostRepositoryInterface $postRepository)
- {
- $this->postRepository = $postRepository;
- }
- public function indexAction()
- {
- return new ViewModel([
- 'posts' => $this->postRepository->findAllPosts(),
- ]);
- }
- }
Add Comment
Please, Sign In to add comment