Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class ArticleFacade {
- /** @var ArticleRepository */
- private $articleRepository;
- /** @var ArticleService */
- private $articleService;
- public function __construct(ArticleRepository $articleRepository, ArticleService $articleService) {
- $this->articleRepository = $articleRepository;
- $this->articleService = $articleService;
- }
- public function getAllArticles()
- {
- return $this->articleRepository->findAll();
- }
- public function find($id)
- {
- return $this->articleRepository->find($id);
- }
- public function getTopArticles(DateTime $since, $maxResults)
- {
- return $this->articleRepository->findArticlesSince($since);
- }
- public function publish($id, DateTime $date) {
- $article = $this->articleRepository->find($id);
- $article->setPublished($date);
- $this->articleRepository->save($article);
- }
- public function add($values)
- {
- $article = new Article();
- $article->setTitle($values["title"]);
- $article->setContent($values["content"]);
- $this->articleRepository->save($article);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement