1 | <?php |
||
46 | class DataProvider implements DataProviderInterface |
||
47 | { |
||
48 | |||
49 | use ConfigureTrait, |
||
50 | CriteriaTrait, |
||
51 | DataTrait, |
||
52 | ModelAwareTrait, |
||
53 | PaginationTrait, |
||
54 | SortAwareTrait; |
||
55 | |||
56 | const CriteriaClass = Criteria::class; |
||
57 | |||
58 | /** |
||
59 | * Finder instance |
||
60 | * @var FinderInterface |
||
61 | */ |
||
62 | private $finder = null; |
||
63 | private $totalItemCount = null; |
||
64 | |||
65 | /** |
||
66 | * Constructor. |
||
67 | * @param mixed $modelClass the model class (e.g. 'Post') or the model finder instance |
||
68 | * (e.g. <code>Post::model()</code>, <code>Post::model()->published()</code>). |
||
69 | * @param array $config configuration (name=>value) to be applied as the initial property values of this class. |
||
70 | * @since v1.0 |
||
71 | */ |
||
72 | 1 | public function __construct($modelClass, $config = []) |
|
77 | |||
78 | /** |
||
79 | * Returns the number of data items in the current page. |
||
80 | * This is equivalent to <code>count($provider->getData())</code>. |
||
81 | * When {@link pagination} is set false, this returns the same value as {@link totalItemCount}. |
||
82 | * @param boolean $refresh whether the number of data items should be re-calculated. |
||
83 | * @return integer the number of data items in the current page. |
||
84 | */ |
||
85 | public function getItemCount($refresh = false) |
||
89 | |||
90 | /** |
||
91 | * Returns the total number of data items. |
||
92 | * When {@link pagination} is set false, this returns the same value as {@link itemCount}. |
||
93 | * @return integer total number of possible data items. |
||
94 | */ |
||
95 | 1 | public function getTotalItemCount() |
|
103 | |||
104 | /** |
||
105 | * Fetches the data from the persistent data storage. |
||
106 | * @return Document[]|Cursor list of data items |
||
107 | * @since v1.0 |
||
108 | */ |
||
109 | 1 | protected function fetchData() |
|
132 | |||
133 | } |
||
134 |