Code Duplication    Length = 4-5 lines in 4 locations

content/content.search.php 2 locations

@@ 46-50 (lines=5) @@
43
44
		$section = SectionManager::fetch($sectionId);
45
46
		if (empty($section)) {
47
			$this->_Result['status'] = Page::HTTP_STATUS_NOT_FOUND;
48
			$this->_Result['error'] = __('Section not found');
49
			return;
50
		}
51
52
		$query = General::sanitize($_GET['query']);
53
		$entries = array();
@@ 55-59 (lines=5) @@
52
		$query = General::sanitize($_GET['query']);
53
		$entries = array();
54
		$filterableFields = $section->fetchFilterableFields();
55
		if (empty($filterableFields)) {
56
			$this->_Result['status'] = Page::HTTP_STATUS_BAD_REQUEST;
57
			$this->_Result['error'] = __('Section not filterable');
58
			return;
59
		}
60
61
		$primaryField = $section->fetchVisibleColumns();
62
		if (empty($primaryField)) {

content/content.sectionsinfos.php 2 locations

@@ 15-19 (lines=5) @@
12
		public function view() {
13
			$sectionIDs = array_map(array('General', 'intval'), explode(',', General::sanitize($this->_context[0])));
14
			
15
			if (empty($sectionIDs)) {
16
				$this->_Result['status'] = Page::HTTP_STATUS_BAD_REQUEST;
17
				$this->_Result['error'] = __('No section id found');
18
				return;
19
			}
20
			
21
			$options = (new SectionsInfos)->fetch($sectionIDs);
22
			
@@ 23-26 (lines=4) @@
20
			
21
			$options = (new SectionsInfos)->fetch($sectionIDs);
22
			
23
			if (empty($options)) {
24
				$this->_Result['status'] = Page::HTTP_STATUS_NOT_FOUND;
25
				$this->_Result['error'] = __('No section found');
26
			}
27
28
			$this->_Result['sections'] = $options;
29
		}