Code Duplication    Length = 51-58 lines in 2 locations

src/PageTypes/EventHolder.php 1 location

@@ 8-65 (lines=58) @@
5
use SilverStripe\ORM\DataList;
6
use SilverStripe\ORM\PaginatedList;
7
8
class EventHolder extends DatedUpdateHolder
9
{
10
    private static $description = 'Container page for Event Pages, provides event filtering and pagination';
11
12
    private static $allowed_children = [
13
        EventPage::class,
14
    ];
15
16
    private static $default_child = EventPage::class;
17
18
    private static $update_name = 'Events';
19
20
    private static $update_class = EventPage::class;
21
22
    private static $icon = 'cwp/images/icons/sitetree_images/event_holder.png';
23
24
    public $pageIcon = 'images/icons/sitetree_images/event_holder.png';
25
26
    private static $singular_name = 'Event Holder';
27
28
    private static $plural_name = 'Event Holders';
29
30
    private static $table_name = 'EventHolder';
31
32
    /**
33
     * Find all site's news items, based on some filters.
34
     * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together.
35
     *
36
     * @param string $className The name of the class to fetch.
37
     * @param int $parentID The ID of the holder to extract the news items from.
38
     * @param int $tagID The ID of the tag to filter the news items by.
39
     * @param string $dateFrom The beginning of a date filter range.
40
     * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for.
41
     * @param int $year Numeric value of the year to show.
42
     * @param int $monthNumber Numeric value of the month to show.
43
     *
44
     * @returns DataList|PaginatedList
45
     */
46
    public static function AllUpdates(
47
        $className = 'Events',
48
        $parentID = null,
49
        $tagID = null,
50
        $dateFrom = null,
51
        $dateTo = null,
52
        $year = null,
53
        $monthNumber = null
54
    ) {
55
        return parent::AllUpdates(
56
            $className,
57
            $parentID,
58
            $tagID,
59
            $dateFrom,
60
            $dateTo,
61
            $year,
62
            $monthNumber
63
        )->Sort('Date', 'ASC');
64
    }
65
}
66

src/PageTypes/NewsHolder.php 1 location

@@ 8-58 (lines=51) @@
5
use SilverStripe\ORM\DataList;
6
use SilverStripe\ORM\PaginatedList;
7
8
class NewsHolder extends DatedUpdateHolder
9
{
10
    private static $description = 'Container page for News Pages, provides news filtering and pagination';
11
12
    private static $allowed_children = [
13
        NewsPage::class,
14
    ];
15
16
    private static $default_child = NewsPage::class;
17
18
    private static $update_name = 'News';
19
20
    private static $update_class = NewsPage::class;
21
22
    private static $icon = 'cwp/images/icons/sitetree_images/news_listing.png';
23
24
    public $pageIcon =  'images/icons/sitetree_images/news_listing.png';
25
26
    private static $singular_name = 'News Holder';
27
28
    private static $plural_name = 'News Holders';
29
30
    private static $table_name = 'NewsHolder';
31
32
    /**
33
     * Find all site's news items, based on some filters.
34
     * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together.
35
     *
36
     * @param string $className The name of the class to fetch.
37
     * @param int $parentID The ID of the holder to extract the news items from.
38
     * @param int $tagID The ID of the tag to filter the news items by.
39
     * @param string $dateFrom The beginning of a date filter range.
40
     * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for.
41
     * @param int $year Numeric value of the year to show.
42
     * @param int $monthNumber Numeric value of the month to show.
43
     *
44
     * @returns DataList|PaginatedList
45
     */
46
    public static function AllUpdates(
47
        $className = NewsPage::class,
48
        $parentID = null,
49
        $tagID = null,
50
        $dateFrom = null,
51
        $dateTo = null,
52
        $year = null,
53
        $monthNumber = null
54
    ) {
55
        return parent::AllUpdates($className, $parentID, $tagID, $dateFrom, $dateTo, $year, $monthNumber)
56
            ->Sort('Date', 'DESC');
57
    }
58
}
59