Passed
Push — 1.8 ( 8b2854...6b63e4 )
by Robbie
15:17 queued 11:24
created

NewsHolder   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
dl 0
loc 38
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A AllUpdates() 0 4 1
1
<?php
2
3
class NewsHolder extends DatedUpdateHolder {
4
5
	private static $description = 'Container page for News Pages, provides news filtering and pagination';
0 ignored issues
show
introduced by
The private property $description is not used, and could be removed.
Loading history...
6
7
	private static $allowed_children = array('NewsPage');
0 ignored issues
show
introduced by
The private property $allowed_children is not used, and could be removed.
Loading history...
8
9
	private static $default_child = 'NewsPage';
0 ignored issues
show
introduced by
The private property $default_child is not used, and could be removed.
Loading history...
10
11
	private static $update_name = 'News';
0 ignored issues
show
introduced by
The private property $update_name is not used, and could be removed.
Loading history...
12
13
	private static $update_class = 'NewsPage';
0 ignored issues
show
introduced by
The private property $update_class is not used, and could be removed.
Loading history...
14
15
	private static $icon = 'cwp/images/icons/sitetree_images/news_listing.png';
0 ignored issues
show
introduced by
The private property $icon is not used, and could be removed.
Loading history...
16
17
	public $pageIcon =  'images/icons/sitetree_images/news_listing.png';
18
19
	private static $singular_name = 'News Holder';
0 ignored issues
show
introduced by
The private property $singular_name is not used, and could be removed.
Loading history...
20
21
	private static $plural_name = 'News Holders';
0 ignored issues
show
introduced by
The private property $plural_name is not used, and could be removed.
Loading history...
22
23
	/**
24
	 * Find all site's news items, based on some filters.
25
	 * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together.
0 ignored issues
show
Bug introduced by
The type The was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
	 *
27
	 * @param $className The name of the class to fetch.
28
	 * @param $parentID The ID of the holder to extract the news items from.
29
	 * @param $tagID The ID of the tag to filter the news items by.
30
	 * @param $dateFrom The beginning of a date filter range.
31
	 * @param $dateTo The end of the date filter range. If empty, only one day will be searched for.
32
	 * @param $year Numeric value of the year to show.
33
	 * @param $monthNumber Numeric value of the month to show.
34
	 *
35
	 * @returns DataList | PaginatedList
36
	 */
37
	public static function AllUpdates($className = 'NewsPage', $parentID = null, $tagID = null, $dateFrom = null,
38
			$dateTo = null, $year = null, $monthNumber = null) {
39
40
		return parent::AllUpdates($className, $parentID, $tagID, $dateFrom, $dateTo, $year, $monthNumber)->Sort('Date', 'DESC');
41
	}
42
}
43
44
class NewsHolder_Controller extends DatedUpdateHolder_Controller {
45
	private static $allowed_actions = array(
0 ignored issues
show
introduced by
The private property $allowed_actions is not used, and could be removed.
Loading history...
46
		'rss',
47
		'atom'
48
	);
49
50
	public function rss() {
51
		$rss = new RSSFeed(
52
			$this->Updates()->sort('Created DESC')->limit(20),
53
			$this->Link('rss'),
54
			$this->getSubscriptionTitle()
55
		);
56
		$rss->setTemplate('NewsHolder_rss');
57
		return $rss->outputToBrowser();
58
	}
59
60
	public function atom() {
61
		$atom = new CwpAtomFeed(
62
			$this->Updates()->sort('Created DESC')->limit(20),
63
			$this->Link('atom'),
64
			$this->getSubscriptionTitle()
65
		);
66
		$atom->setTemplate('NewsHolder_atom');
67
		return $atom->outputToBrowser();
68
	}
69
}
70