Completed
Push — dev ( da0648...23d1c0 )
by Nicolas
01:15
created

view()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 11

Duplication

Lines 9
Ratio 50 %

Importance

Changes 0
Metric Value
dl 9
loc 18
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 11
nc 3
nop 0
1
<?php
2
	/*
3
	Copyright: Deux Huit Huit 2014
4
	LICENCE: MIT http://deuxhuithuit.mit-license.org;
5
	*/
6
7
	require_once(TOOLKIT . '/class.jsonpage.php');
8
	require_once(EXTENSIONS . '/entry_relationship_field/lib/class.sectionsinfos.php');
9
10
	Class contentExtensionEntry_relationship_fieldSectionsinfos extends JSONPage {
11
		
12
		public function view() {
13
			$sectionIDs = array_map(array('General', 'intval'), explode(',', General::sanitize($this->_context[0])));
14
			
15 View Code Duplication
			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 View Code Duplication
			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
		}
30
	}
31