Completed
Push — master ( 68f946...ae8931 )
by Leo
02:20
created

PrintBlocks::getDockedBlocks()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 2
Metric Value
c 3
b 0
f 2
dl 0
loc 12
rs 9.4285
cc 3
eloc 8
nc 3
nop 0
1
<?php
2
class PrintBlocks extends Extension {
3
	
4
	public function getAllBlocks() {
5
		$blocks = new ArrayList();
6
		$blocks->merge($this->getMyBlocks());
7
		$blocks->merge($this->getDockedBlocks());
8
		return $blocks;
9
	}
10
		
11
	public function getMyBlocks() {
12
		return $this->owner->Blocks()->sort(array('SortOrder' => 'ASC', 'ID' => 'ASC'));
13
	}
14
	
15
	public function getDockedBlocks() {
16
		$blocks = Block::get()->filter('showBlockbyClass', true);
17
		$blocks_map = $blocks->map('ID', 'shownInClass');
18
		foreach ($blocks_map as $blockID => $Classes) {
19
			$Classes = explode(',', $Classes);
20
			if (!in_array($this->owner->ClassName, $Classes)) {
21
				$blocks = $blocks->exclude('ID', $blockID);
22
			}
23
		}
24
		
25
		return $blocks->sort('SortOrder', 'ASC');
26
	}
27
}