equal
deleted
inserted
replaced
|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the Pagerfanta package. |
|
5 * |
|
6 * (c) Pablo Díez <pablodip@gmail.com> |
|
7 * |
|
8 * For the full copyright and license information, please view the LICENSE |
|
9 * file that was distributed with this source code. |
|
10 */ |
|
11 |
|
12 namespace Pagerfanta\View; |
|
13 |
|
14 use Pagerfanta\PagerfantaInterface; |
|
15 |
|
16 /** |
|
17 * OptionableView. |
|
18 * |
|
19 * This view renders another view with a default options to reuse them in a project. |
|
20 * |
|
21 * @author Pablo Díez <pablodip@gmail.com> |
|
22 * |
|
23 * @api |
|
24 */ |
|
25 class OptionableView implements ViewInterface |
|
26 { |
|
27 private $view; |
|
28 private $defaultOptions; |
|
29 |
|
30 /** |
|
31 * Constructor. |
|
32 * |
|
33 * @param ViewInterface $view A view. |
|
34 * @param array $options An array of default options (optional). |
|
35 * |
|
36 * @api |
|
37 */ |
|
38 public function __construct(ViewInterface $view, array $defaultOptions = array()) |
|
39 { |
|
40 $this->view = $view; |
|
41 $this->defaultOptions = $defaultOptions; |
|
42 } |
|
43 |
|
44 /** |
|
45 * {@inheritdoc} |
|
46 */ |
|
47 public function render(PagerfantaInterface $pagerfanta, $routeGenerator, array $options = array()) |
|
48 { |
|
49 return $this->view->render($pagerfanta, $routeGenerator, array_merge($this->defaultOptions, $options)); |
|
50 } |
|
51 |
|
52 /** |
|
53 * {@inheritdoc} |
|
54 */ |
|
55 public function getName() |
|
56 { |
|
57 return 'optionable'; |
|
58 } |
|
59 } |