1 <?php
2
3 /*
4 * This file is part of the Icybee package.
5 *
6 * (c) Olivier Laviale <olivier.laviale@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 Icybee\Modules\Articles;
13
14 class ArchivesView extends \Icybee\Modules\Views\View
15 {
16 /**
17 * Returns records grouped by month.
18 *
19 * @see Icybee\Modules\Views.View::provide()
20 */
21 protected function provide($provider, &$context, array $conditions)
22 {
23 $records = parent::provide($provider, $context, $conditions);
24
25 $by_month = array();
26
27 foreach ($records as $record)
28 {
29 $date = substr($record->date, 0, 7) . '-01';
30 $by_month[$date][] = $record;
31 }
32
33 return $by_month;
34 }
35 }